PNGEncoder2 icon indicating copy to clipboard operation
PNGEncoder2 copied to clipboard

Error: Error #1000: The system is out of memory. at flash.utils::ByteArray/readBytes() at _PNGEncoder2::PNGEncoder2Impl$/writeIDATChunk() at _PNGEncoder2::PNGEncoder2Impl/onEnterFrame()

Open matrix3d opened this issue 8 years ago • 9 comments

Error: Error #1000: The system is out of memory. at flash.utils::ByteArray/readBytes() at _PNGEncoder2::PNGEncoder2Impl$/writeIDATChunk() at _PNGEncoder2::PNGEncoder2Impl/onEnterFrame()

matrix3d avatar Feb 26 '17 04:02 matrix3d

Yes? How big is the bitmap you're trying to compress? Have you tried a profiler to see where the memory is going? More details, please! :-)

cameron314 avatar Feb 27 '17 14:02 cameron314

it is this https://github.com/cameron314/PNGEncoder2/issues/5 work good for me.

but is it there a decoder from file?

matrix3d avatar Feb 28 '17 03:02 matrix3d

Great, I'm glad the IDataOutput version works for you.

Yes, in the same gh-IDataOutput branch, there's a decode method that accepts an IDataInput. It's synchronous and only works on PNGs encoded with PNGEncoder2, though.

cameron314 avatar Feb 28 '17 14:02 cameron314

my code.

chaifenfile = fs[0] as File;
			var fs2:FileStream = new FileStream;
			fs2.open(chaifenfile, FileMode.READ);
			var bmd:BitmapData = PNGEncoder2.decode(fs2);
			trace(bmd.width, bmd.height);

and get Error #1000: The system is out of memory.

matrix3d avatar Mar 06 '17 13:03 matrix3d

and use flash loader,also out of memory.

var chaifenloader:Loader = new Loader;
			chaifenloader.contentLoaderInfo.addEventListener(Event.COMPLETE, chaifenloader_complete);
			chaifenloader.load(new URLRequest(chaifenfile.url));

matrix3d avatar Mar 06 '17 13:03 matrix3d

i just want split the big image 2 a lot of small images. so can i just get the png width,and height from a file? and get the sub bitmapdata from rect?

matrix3d avatar Mar 06 '17 13:03 matrix3d

Hmm. Looks like the bitmap really is just too big to load in flash (what is its width/height?).

You can get the width and height from the header of the PNG file, but the pixel data is pre-processed, compressed, and split up across several "IDAT" chunks in the file, which means it's impossible to access an arbitrary section of the image given just the coordinates (the whole file has to be scanned, decompressed, and post-processed from start to finish before any pixels can be accessed).

Can you split the big image into smaller images when you save it instead of when you load it?

cameron314 avatar Mar 06 '17 14:03 cameron314

the image not too big.just 275m.15616x8960px

matrix3d avatar Mar 06 '17 15:03 matrix3d

Ah. That's a big image :-)

When loading a PNG, the bitmap ends up being in memory twice (since there's the raw uncompressed memory from the decode step plus the Flash bitmap object created from that raw memory, before the raw memory can be deallocated) plus the compressed version too (which at least isn't loaded all at once into memory in my IDataInput version, but still).

With transparency, there's 4 bytes per pixel (of uncompressed raw pixel data), for a total minimum memory requirement of 533MB*2 = ~1GB. Without transparency, there's only 3 bytes per pixel required, which comes to 400MB*2 = 800MB. So, it's understandable that flash is running out of memory.

cameron314 avatar Mar 06 '17 18:03 cameron314