c# - BitmapEncoder SetPixelData memory allocation -


i'm working on metro application need generate animated gif image.

i've found this tutorial, witch seems 1 , resource on animated gifs metro apps.

when running code, exception thrown on setpixeldata method, telling me the allocated buffer memory insufficient (the message in os language though visual studio environnement in english, think might relevant).

i've reduced image size (source , output) , frame number, still error. (i manipulate way bigger images , byte array in same application).

any idea memory problem can come ? problem storagefile maybe ?

i seeing exception when framewidth\height being passed setpixeldata didn't match pixel data.

i ended example below. seeing exception mentioned when dimensions didn't match pixeldata.

i think more stable in windows 8.1 doesn't repro on it.

bitmapdecoder decoder = await bitmapdecoder.createasync(sourcestream);                 bitmaptransform transform = new bitmaptransform()                 {                     scaledheight = 900,                     scaledwidth = 600                 };                 pixeldataprovider pixeldata = await decoder.getpixeldataasync(bitmappixelformat.rgba8,                                                                               bitmapalphamode.straight,                                                                               transform,                                                                               exiforientationmode.respectexiforientation,                                                                               colormanagementmode.donotcolormanage);                  storagefile destinationfile = await applicationdata.current.localfolder.createfileasync(path.combine(database.rootmoviesfolderspaths, movie.localid + ".jpg"));                 using (var destinationstream = await destinationfile.openasync(fileaccessmode.readwrite))                 {                     bitmapencoder encoder = await bitmapencoder.createasync(bitmapencoder.jpegencoderid, destinationstream);                     encoder.setpixeldata(bitmappixelformat.rgba8, bitmapalphamode.premultiplied, 600, 900, 96, 96, pixeldata.detachpixeldata());                     await encoder.flushasync();                      movie.hasfolderimage = true;                      return true;                 }             } 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -