This is a blog about Flash by betaruce :-)

Calendar

February 2006
M T W T F S S
« Jan    
  1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28  

August 18, 2005

Output JPG Image from Flash

Filed under: My Flash Programs — betaruce @ 9:15 pm

With the new BitmapData class and PHP, we can output JPG images from Flash easily :)

Click here

The principal behind it is simple: Simply get all the pixel color values and pass them to php, and php will generate the JPG.

• • •

13 Comments »

  1. thats interesting

    Comment by Dominick — August 18, 2005 @ 9:39 pm
  2. Fantastic! Will you be publishing the source? This is something I’ve wanted to do from Flash for a longtime - I’ve done it with Director/Shockwave before, but the ubiquity of the Flash plugin will make things much easier…

    Comment by Kent — August 18, 2005 @ 10:12 pm
  3. beta-testers can only publish swf samples online now….
    I think after Flash 8 is officially issued, I will post the code out :)

    Comment by betaruce — August 18, 2005 @ 10:52 pm
  4. Thanks, I’m looking forward to Flash 8, one because then I can play with it, and two because it looks like there’s going to be a wealth of source-code sharing too :>

    Comment by Kent — August 19, 2005 @ 12:04 am
  5. I looked into this, too, the problem is that you get huge amounts of data, even with fairly small images. An image of 300*200 has 60000 pixels, a color value is 6 digits, which results in about 360kb of data. So unless you find a way to stream or compress data you need to keep your images small or have long waiting times. Have you found a good way to manage this?

    Comment by Christoph — August 19, 2005 @ 12:17 am
  6. yes that’s right. Becoz my testing server has memory limit, I cannot even have a 300*300 image if I use this method. That’s why I finally choose 200*200. I’m thinking of a better way. What do you think?

    Comment by betaruce — August 19, 2005 @ 12:59 am
  7. Well, we would just have to find a way to reduce data. Wikipedia has some good info on image compression, I have never looked into the topic though, seems pretty complex if you want to get good results. Who knows, maybe Flash 8 has some more tricks up its sleeve for this purpose.

    Comment by Christoph — August 19, 2005 @ 7:16 am
  8. i will see if Flash 8 can do anything. Thanks for your comments :)

    Comment by betaruce — August 19, 2005 @ 8:18 am
  9. I was working on this for a long time under Flash8.
    It takes to much time to collect the information and compress it.
    I guess we found the next item in the wish list. :)
    i recently found out that, browsers can decompress GZIPED html or css files. This means Flash needs to have a basic compressor/decompressor build in. Like LZW or something.
    Macromedia is neglecting the application possiblities of BitmapData > Upload scheme.

    Comment by Ali Tan Ucer — August 19, 2005 @ 10:29 am
  10. i’ve thought of a “stupid” way to do it.
    say e.g. i hv a 400*400 image on Flash
    i make it 200*200 by BitmapData and Matrix, then output the pixels of this scaled image.
    Then in php each pixel value was used for 4 times (to form a square of size 2*2), then we can hv a 400*400 image but decreased resolution…..

    Comment by betaruce — August 19, 2005 @ 4:38 pm
  11. btw, actually the main problem is the transfer of data from flash to php as there’s too much data. so it seems to work if i first output these data into a txt file and then run the php which get the values from the txt file.

    i will try this out later.

    Comment by betaruce — August 19, 2005 @ 6:33 pm
  12. so are you currently outputting each pixel as a colour to php to build the image? I was wondering about the delay and the php file :>

    So I guess I’m still waiting for my Export File function…

    Comment by kent — August 19, 2005 @ 6:56 pm
  13. yes php need some time to process the data
    yet i think the delay is not so significant.

    Comment by betaruce — August 20, 2005 @ 12:29 am

Comments RSS • TrackBack URI

Leave a comment

Powered by: WordPress • Template by: Priss