AS3 PNG Encoder without BitmapData

62 Views Asked by At

Simply stated, I'm looking for a PNG encoder that will directly convert a RGB/RGBA ByteArray into a PNG file also stored in a ByteArray without making use of the BitmapData class at all. I'm currently working on a ~v4.0 Scaleform Gfx project - which doesn't support any of the Get/SetPixel methods.

1

There are 1 best solutions below

0
On

If you're using Scaleform 4.0, then likely your best solution is to bind the ByteArray in question to a GFx::Value in C++, via an ExternalInterface call. With the GFx::Value, you can use ReadByteArray, WriteByteArray, etc.

Scaleform 4.0 by default has a PNG reader/writer built in, Scaleform::Render::PNG::FileReader/FileWriter. These basically just wrap libpng functionality. You can use Scaleform::MemoryFile to wrap the incoming/outgoing bytes, so they can use this interface.

Alternatively, if you'd like to use the BitmapData API, you could upgrade to the final version of Scaleform, which is available from Autodesk support for free, assuming you have a valid license.