File I/O API: FileStream.writeImage does not work

Forums » Dev.Opera » Archived Opera Widgets Development Discussions

You need to be logged in to post in the forums. If you do not have an account, please sign up first.

Go to last post

6. May 2010, 22:34:32

pwojke

Posts: 2

File I/O API: FileStream.writeImage does not work

I'm trying to save images with the File I/O API and FileStream#writeImage.

I would have expected that it saves the same data as provided by the server. What I got when trying to safe http://imgs.xkcd.com/comics/cemetery.png was this mess:
- The image is stored as JPEG instead of PNG. Compression artifacts are clearly visible.
- Writing failed after about 10kb with a GENERIC_ERR. Opening the saved part shows half the image is missing.

The only way I could work out to save an image is this:
- Create an canvas an draw image on canvas.
- Get a data URL from the canvas.
- Store the data with FileStream#writeBase64

This works, but is far from optimal:
- Image size for large JPEGs may increase significantly.
- Only one frame from animated GIFs will be saved.
- Its not the original image.

The API documentation and examples don't help much and a forum search shows now results. Looking at other widgets that save images shows that they use canvas too.

Has somebody successfully saved an image with writeImage?

Using Opera 10.53 on Windows XP.

Forums » Dev.Opera » Archived Opera Widgets Development Discussions