0

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

laurent
  • 88,262
  • 77
  • 290
  • 428
theB
  • 2,048
  • 2
  • 20
  • 29
  • JavaScript in a browser? How can you not have access to CSS if you have access to JavaScript? – laurent Mar 08 '12 at 06:30
  • 1
    Actually not in browser. I'm trying in Yahoo! widget. And I'm new to that. So I'm not sure it supports css (actually it supports some styles. but not transform, image-orientation, etc), DOM, canvas. – theB Mar 08 '12 at 06:33

2 Answers2

1
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.

Kevin
  • 532
  • 2
  • 7
  • That even not supports XMLHttpRequest. And we dropped that work. So currently I am not interested in it. If possible somebody close this post or tell me how to close it. – theB Jun 07 '12 at 13:12
1

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.

laurent
  • 88,262
  • 77
  • 290
  • 428
  • 1
    can you please elaborate a little bit. Actually I don't have access to the yahoo widget website (URLs having yahoo in them are blocked). And I have only documents 1.Widget_Creation_Tutorial_1.1 2.YWE_TV_Widget_Developer 3.YWE_TV_Widget_KONtx 4.YWE_TV_Widget_QuickStart 5.YWE_TV_Widget_Install 6.YWE_TV_Widget_Media_Player In those documents I can't found what you have mentioned. Can you please help me in this case. – theB Mar 08 '12 at 06:49
  • Hmm... you need to download the documentation or else you won't be able to do much with Yahoo! Widgets. Maybe download it from a different computer or search for it on Google. It's called something like "Konfabulator 4.5 1113 - edit.pdf" – laurent Mar 08 '12 at 07:04
  • 1
    One more thing. We are not developing for Windows or MAC. We are working for TV widgets. Whether the Canvas thing is possible for us? – theB Mar 08 '12 at 07:04
  • 1
    For Canvas, you can have a look at Firefox's documentation. I believe the API is the same - https://developer.mozilla.org/en/Drawing_Graphics_with_Canvas – laurent Mar 08 '12 at 07:06
  • 1
    Thanks a lot for your help friend. Whatever you told was for Windows widget. But I'm working in TV widgets. – theB Mar 08 '12 at 07:18
  • Not sure why they would make the API different for the TV widgets. Might be worth trying Canvas anyway. – laurent Mar 08 '12 at 11:07