Reputation: 2238
Is there a way in javascript for binary file manipulation like C. I'm in a critical situation to create an fliped image. I don't have support for css, canvas, HTML, DOM. But I have to do that with only using javascript. If it allows me to load an image into a byte array I can parse each byte and will create a new image. Is there really a way.....?!
thanks in advance
Upvotes: 0
Views: 2121
Reputation: 532
var xhr = new XMLHttpRequest;
xhr.open("GET", "/images/someing.png", true);
xhr.responseType = "arraybuffer";
xhr.onload = function () {
var data;
data = new Uint8Array(xhr.response || xhr.mozResponseArrayBuffer);
};
This won't work in the current version of IE, so I'm not sure how a widget would handle it. This allows you to read a png into a byte array though.
Upvotes: 1
Reputation: 90804
If it's Yahoo! Widgets it's a different issue. The Canvas
class allows you to load an image using 'drawImage()', then you can use scale
with negative values to flip the image. See the reference manual at Canvas
for more information.
Upvotes: 1