createImageBitmap with resize: doesn't work on Chrome? - javascript

Looking at the MDN page for createImageBitmap it states that Chrome supports the options parameter from 52 onwards. But in testing with Chrome 57, I can't seem to get the resizeWidth or resizeHeight options to work. I've got a demo running here:
https://codepen.io/anon/pen/YVwrXN
From my understanding, what I've provided should end up with an image bitmap half the size of the original image being drawn to the canvas tag, but it appears to be full size (I know I can rescale in drawImage() but that's not what I'm looking for here). I found some Chromium notes on implementing it that makes it sound like it should work, so I'm wondering if I'm doing something wrong.

As of today, (on both chrome 60 canary and stable 57) you still need to set the Experimental canvas features flag in chrome://flags.
I agree that MDN page should state this.
Edit 2021:
Chrome now supports this natively. But other browsers still don't (Safari doesn't support the API at all). If you need this for cross-browsers projects, I wrote a createImageBitmap monkey-patch which enables this feature in all browsers.

Related

css zoom not working in ie11

I'm building an app using angular. It is supposed to run on tablets and touch-enabled devices.
I want to give the user the ability to zoom/scale up the app, for those with bad eyesight and clumsy fingers. To do this I'm using this script, which is executed when the user clicks a zoom-button:
Here is the code
<!--code start -->
$scope.zoomLevel+= 0.1;
$('body').css({
zoom: $scope.zoomLevel
});
This works perfectly in chrome, but does nothing at all in IE11.
I'm using twitter bootstrap, angular and jquery.
When testing it in jsFiddle I'm perfectly able to use zoom in IE, so I'm guessing that me, or some third party library is setting a property that affects the zoom property in IE.
What could this be?
PS: I don't mind it not working in firefox. This app will always be run in IE11.
The zoom property is an older feature that really shouldn't be leveraged today. It has poor cross-browser support, belongs to no formal standard, and as such I (an engineer on the IE team) would encourage you to find a more standards-compliant method for moving forward.
Since version 9, Internet Explorer has supported CSS Transforms, and the scale function. This particular feature has much better cross-browser support, and would adequately suffice for your needs. I've created a small fiddle that shows both zooming and scaling side-by-side, to confirm the similarity in the experience.
Fiddle: http://jsfiddle.net/jonathansampson/hy5vup49/2/
After some discussion in the comments, you pointed out valid layout differences between zoom and transformational scaling. If you wish to achieve the effect of zoom cross-browser, I would instead encourage you to consider using em or rem units in your project, and leverage font-size inheritance as your zooming mechanism.
Fiddle: http://jsfiddle.net/jonathansampson/024krs33/

Is Chrome Frame really the only choice for improving Raphael performance in IE?

I'm using Raphael 2.1 to draw 15 lines at the same time. Each lines is made up of 50 2 pixel paths. Performance is best in Safari and Chrome, good in FF, weak in Opera, and chokes in IE9. Microsoft says that SVG will run in IE9, but Raphael.svg returns false in IE9.
I've been reading posts related Raphael and IE all day, and the only solution that I've seen for improving Raphael's performance in IE9 is to install Chrome Frame.
Has anyone encountered any other solutions?
Raphael uses svg in IE9 and work with reasonable performance. You have to be careful that IE is not being forced into IE8 standards mode (which frequently happens). If IE9 falls back to IE8 standards then it will end up using VML, which is very slow, and there is no efficient alternative to SVG in general in IE8 or below.
When faced with this problem using IE8 I ended up using divs and css to achieve rendering of lines, rectangles and text. Since that's all I required it was very fast even in IE8, helped out by buffering the divs inside the container. If your problem is simple enough, you may wish to consider a pure DOM solution. See: https://github.com/Matt-Esch/simpleCanvas.js for inspiration.

Supporting and emulatingn HTML5 <canvas> in older IE browsers

I found that excanvas and flashcanvas are the common libraries used for supporting canvas features in Internet Explorer( below 9). But both of them doesn't have implemented all the specification features of canvas.
For example the drawImage() function only accepts image as the source. It does not support either canvas or video. Also there is no implementation available for getImageData(),putImageData()
Which is the best and correct JavaScript library for supporting canvas features in IE browsers? Do we get any other library for IE which exactly mimics the native canvas features?
FlashCanvas Pro support getImageData() and putImageData():
http://flashcanvas.net/docs/canvas-api
but I suggest you to don't try to use canvas on ie<=9
If you need to works with graphics, you can use http://raphaeljs.com/ , it use SVG for modern browsers an VML for ie 6-8
Have you heard about DOM SPRITRES
There is no way to get full canvas support for old IE browsers (IE6 - IE8)
Javascript engine performance is not good enough for emulating all native <canvas> operations
External plug-ins, like Flash, are limited how they can interact with page elements like <img> or other <canvas>
Solutions
Google Chrome Frame provides single click, no admin priviledges needed, plugin which will make older Internet Explorers to use Google Chrome rendering engine when the page requests so. It will turn Internet Explorer Chrome internally and the user doesn't see the difference. The downside is single click plugin install and download time.
Don't support old browsers
Do not use <canvas> if you need to support old browsers
Use <canvas> emulation feature set which works in all browser - this is the most painful solution and I suggest you simply don't try to do it, because sooner or later you'll encounter something that doesn't work in <canvas> emulators

-moz-calc crossbrowser (polyfills? hooks?)

I'm working on some project currently in which I'm using LESS, CSS3 and some other "fancy" technologies. I have some piece of code which calculate height for me:
height: -moz-calc(100% - 40px);
I also use -moz-calc in couple other places to calculate some stuff. The problem is to make it working crossbrowser (O, Safari, Chrome, IE8+). It's kinda tricky even when I try to do it via JS (jquery), but some cases are really tricky unfortunately. So I'm looking for some kind of bullet proof solution with automatic updates, just like it was CSS' calc().
Webkit just landed prefixed calc() support. -webkit-calc() currently works in the Chrome dev build and should be included in the next release of Chrome and Safari.
http://caniuse.com/calc
https://developer.mozilla.org/en/CSS/calc
-webkit-calc (Available in the Chrome 19 Dev build, Should be available in the next Safari)
calc (IE9)
--- (Opera does not support it yet)

Can we use canvas.toDataURL on IE7 and IE8?

I am using toDataURL() method of a canvas object. It works on IE9 and Chrome.
But it is not supporting for IE7 and IE8. I found this link
https://github.com/sampula/SVG.toDataURL/commit/9b59af148b7f14d41974cf318eed6f84c8c91062
It extends SVG to use toDataURL(). But in its implementation, it again uses canvas.toDataURL(). I am using Google's API (jquery.flot.js) for plotting all the graphs graphs. But it also uses canvas to plot the graph. So, SVG is not an option.
I there ever a way to use canvas.toDataURL() or something similar for IE7 and IE8.
Thanks in advance
IE7/8 does not support either Canvas or SVG.
It does however support VML, which is a vector language similar to SVG, and there are a number of javascript-based hacks for IE that use its VML functionality to emulate both Canvas and SVG in this older browser.
The most well known IE-Canvas hack is this one: http://code.google.com/p/explorercanvas/
I haven't spent much time with it myself, so I can't vouch for whether it can do specific functionality such as the toDataURL() method you're asking about, but if you can't do it with this, then it's unlikely to be possible at all.
I mentioned that there are similar tools for VML->SVG as well. If that's of interest to you, then you might want to look into this one: http://code.google.com/p/svg2vml/
Bear in mind that no matter how clever these hacks are, there is always a fundamental issue of performance. IE7/8's javascript interpreter is very slow by modern standards, and these are javascript-based tools trying to shoehorn very modern functionality into this old browser. They may well work, but don't try to do anything too clever with your canvas or SVG, or you'll kill the browser.
Finally, since you mentioned that you're using all this to draw graphs, I will point out the graphing module of the Raphael library. Raphael is a library which draws SVG graphics on all browsers (falling back to VML for IE). The graphing module provides all the usual graph types, wrapped in an extremely easy-to-use javascript API. And it is fully cross-browser compatible -- it works on all desktop browsers out of the box from the latest Chrome and Firefox all the way back to IE6. If you're struggling with cross-browser compatibility with the tools you're using now, you may want to switch to this library.
Hope that helps.
I have recently created an application in which I had to use toDataURL() but I was not able to find any way to do this in IE7/8. My application was an online image editor in which user was able to save the canvas contents. I believe there is not way we can use this method in IE7/8.

Categories

Resources