— Shang Liang

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.

>>source<<

1 comment
  1. astgtciv says: May 16, 20071:30 pm
Submit comment

For spam filtering purposes, please copy the number 1707 to the field below: