Playing GIF in Flash
In my recent project, I need to generate a thumbnail from the user’s screen. BitmapData is the only solution. The algorithm is straight forward, read the color of every pixel -> save them -> redraw every pixel according to the recorded colors.
In order to compress the size, I first tried to create an color pallet and map the pixels of the image to the pallet. But then the pallet is huge. When Flash reads the colors, a JPG file has 2000+ colors. No choice, I need to do what GIF has done. I recalculated the colors and one image can only have 256 colors. The result is quite acceptable, a 60×40 size thumbnail is around 10KB. The color restriction process bring down the file size by 3 folds.
xref http://www.quasimondo.com/archives/000572.php .