blog
Tag Archive for ByteArray at Jozef Chúťka's blog
January 7, 2011
ByteArray compress gzip gzuncompress lzma zip
Quick Tip: Compression in Flash
While working on one of my projects where I needed compression for transfered data, I hit some very interesting compression libraries. Also the ByteArray class contains compress method, using zlib algorithm in flash player or multiple algorithms in AIR. At the end I decided to use ByteArray.compress() method for encoding vs. PHP gzuncompress for decoding, what works correctly, fast and smooth.
Here is a list of 3rd party compression libraries and other good stuff:
AS3 Zip: ActionScript 3 based library for reading and writing zip files
FZip: FZip is an Actionscript 3 class library to load, modify and create standard ZIP archives.
ASZip: ActionScript 3 library to generate ZIP files
LZMA Encoder: AS3 class to compress data using LZMA algorithm.
LZMA Decoder: A part of the apparat framework.
GZIP: ActionScript GZIP compression library
Gzip for HTTPService/URLLoader: Adding Gzip support for Flex/AIR HTTPService/URLLoader
airxzip: Zip library for ActionScript3 on AIR
If you know some more, please let me know.
October 25, 2010
BitmapData ByteArray compress imagecolorallocate imagesetpixel unpack
Processing BitmapData.getPixels() With PHP
Have you ever worked with BitmapData.getPixels() method? This method generates a byte array from a rectangular region of pixel data. Writes an unsigned integer (a 32-bit unmultiplied pixel value) for each pixel into the byte array. Thats sounds good, but what is it good for to have a ByteArray full of integers? There is not even a decoder for this format on my backend?!… Well, this format is so cool, and easy to access that you do are able to write your own decoder e.g. in PHP.
The resulting bytes are 32-bit unsigned integers for each pixel represented by AARRGGBB format, followed by another pixels and so on e.g.:
AA RR GG BB:
-- -- -- --
FF FF 00 00
00 00 FF 00August 2, 2010
ByteArray Endian pixel bender Shader ShaderJob Vector
Pixel Bender Inputs – Vector or ByteArray

Pixel Bender for Flash Player lets you play some more advanced games. Based on your needs you can force your kernels to “eat” not only BitmapData, but also ByteArray-s or Vector-s. With this knowledge, you can simply use Pixel Bender kernels for some fast math or processing like 3D engines (3D to 2D projection) etc. Lets have a look at some simple demos, how to push vector and raw bytes directly into shader via ShaderJob:
February 16, 2010
base64 Bitmap ByteArray ExternalInterface PNGEncoder
Inline Images

Have you ever heard about inline images? Inline images use the data URI scheme to embed images directly within web pages. As defined by RFC 2397, data URIs are designed to embed small data items as “immediate” data, as if they were referenced externally. This basicaly means, you can insert base64 encoded byte code of any image directly into html file. Using inline images saves HTTP requests over externally referenced objects. Data URIs can potentially store any type of data, not just images!
November 30, 2009
base64 ByteArray compress convert hex p16Top64 p64Top16 readUnsignedInt writeUnsignedInt
Compressing hex string into base64 string

How would you convert / compress 64 character long hex string (0-9a-f) into shortest possible web-safe-char string? (base64 chars is fine) The reverse algorithm must be able to “uncompress” resulting string back into original hex.
I have created p16Top64() compress algorithm and p64Top16() uncompress (reversed) algorithm based on ByteArray class and writeUnsignedInt(), readUnsignedInt() methods. Both p16Top64() and p64Top16() methods are now part of sk.yoz.data.Serialization class. By using p16Top64() method I was able to compress original 64 chars into 44 chars. But, is it possible to compress it into less than 44 char long base64 (0-9a-Z/=) string?
October 15, 2009
Bitmap BitmapData ByteArray converting DisplayObject encoding image Loader LoaderInfo url URLRequest
Bitmap, BitmapData, ByteArray…

Lets see how to convert between Bitmap, BitmapData and ByteArray in few examples:
DisplayObject to BitmapData
BitmapData to Bitmap
BitmapData to ByteArray
URL (image) to ByteArray (asynchronous)
URL (image) to BitmapData (asynchronous)
ByteArray to BitmapData (asynchronous)
October 13, 2009
ActionScript ByteArray serialization String
Serialization
This classes let you serialize your ActionScript 3 Objects to ByteArray or String:
October 9, 2009
alchemy asynchronous Bitmap BitmapData ByteArray converting encoding image jpeg JPEGEncoder
ActionScript 3 encoding JPEG, alchemy
Lets assume you want to save an image (or any DisplayObject) from flash to disk, or upload to facebook etc. What you need is to encode your BitmapData into an Jpeg and send ByteArray raw data to be saved/uploaded. There are few ways how to do it.
First, you can use original adobe mx.graphics.codec.JPEGEncoder. Sadly, this encoder is the slowest. There were attemps to make it faster by otpimizing code by bytearray.org, that resulted into two times faster org.bytearray.images.JPEGEncoder. Usage is pretty simple: