September 28, 2002
Dynamic JPEG Masking

Recently on Flashcoders the question came up if it is possible to mask JPEGs based on a color value, similar to GIFs where one color can be reserved for transparency. Well, I created a little application based on my image-to-pixelinfo script that demonstrates the possiblities. You can upload an image and pick a color range that should be masked or un-masked.

On my machine this runs faster than I expected first based on whats actually happening behind the scenes. The current approach I would call brute force attack: The code traverses line by line through the image and checks if the current pixel has a color in the mask range or not. If yes it draws a pixel-sized rectangle at that position. I use a tiny optimization already: Horizontally neighbored mask pixels are combined into one long rectangle. Still the optimum code that I could imagine would be a kind of tracing routine that follows the surface of the masked areas. The question is what would be faster and how to do that.

Posted at September 28, 2002 07:24 PM | Further reading
Comments

(concerning upload of JPEG)...That was very cool. I have a debate raging with friends of mine...would you settle it for me? The upload image part< does that actually upload an image from th users drive to a file on the server that Flash uses?? Could it be done any other way?

Just curious.

Posted by: micky on October 17, 2002 10:19 PM

At the moment the upload takes a picture from the users harddrive, but it could also grab an image from an URL that you enter. Or it could search Google for some images. As long as it is a JPEG or PNG it can handle it.

Posted by: coma2mario on October 18, 2002 10:10 AM

I found a script (perl) that can wrap a non progressive JPEG to a SWF. But to use any JPEG or PNG is better.
I know about swift-generator. But he his to bulky for fast converts and got some bugs there.
Your converter is closed source I guess?

URL (jpeg2swf with perl): http://spv.virtualave.net/jpeg2swf/

Posted by: max0matic on November 28, 2002 10:27 PM

Is it possible to get the source code of the upload script...?? Ive been looking for a script just like that... And i havent got the experience to make one myself...

Posted by: dc2003 on January 24, 2003 02:06 AM

Any chance on you posting the upload script? It would be much appreciated!!.

Posted by: ronin on June 24, 2003 05:57 AM

Any chance on you posting the upload script? It would be much appreciated!!.

Posted by: ronin on June 24, 2003 05:57 AM

how do you do pixel operations? or for that matter, dynamically load PNG images into flash. as far as i know neither of these are supported.

Posted by: inquaman on October 31, 2003 10:29 PM

On http://www.quasimondo.com/archives/000104.php I've explained the technique how to get all the RGB pixel values of an image in a reasonable sized file.

Posted by: Mario on October 31, 2003 11:07 PM

hi,
It's wonderful to hear that you've made a masking allowed background color specifying.
I tried to load a small jpg, followed your link "application". But can not load.
I would like to know more about your application. Can you tell me please?
Tuan Vo

Posted by: Tuan Vo on March 5, 2004 08:23 AM

Thanks for telling me. It looks like I accidently deleted on file. It should work again now.

Posted by: Mario Klingemann on March 5, 2004 10:53 AM

I, too, would love to know how to facilitate uploading a binary image file, or for that matter any file, from a user's computer to a server, via Flash. Just like lots of other people on here, it would seem.

Posted by: Raymond Brigleb on April 23, 2004 09:18 PM

Not know were else to post this:
It's a super effect the Bitmap Effects (the link is also to he left of this site)
http://www.quasimondo.com/flash.bitmap.effects/index.php

But is it not porsibel to get the .fla file?

Posted by: Jacob Boesby on May 27, 2004 03:54 PM

It doesn' work anymore

Posted by: Ziyad Saeed on June 10, 2005 06:06 AM

Oh indeed - thanks for telling me! I'll try to fix that ASAP.

Posted by: Mario Klingemann on June 12, 2005 11:31 PM

Hi this is great how is this dynamic masking done though? is there a source for this???

Posted by: Brian Theuma on October 7, 2005 10:38 PM

As you see, this demo is three years old now. With Flash 8 you just have to use one filter to get this effect.

Posted by: Mario Klingemann on October 8, 2005 12:34 AM

hi there! i was wondering if the source is available...

Posted by: Beck on November 16, 2005 11:18 PM
Post a comment
Name:


Email Address:


URL:


Comments:


Remember info?



Thank you!

Most Visited Entries
Sketches, Works & Source Code
Lectures
Contact
Backlog
In Love with
Powered by
Movable Type 2.661

© Copyright Mario Klingemann

Syndicate this site:
RSS 1.0 - RSS 2.0

Quasimondo @ flickr
Quasimondo @ LinkedIn
Quasimondo @ Twitter
Quasimondo @ Facebook
Quasimondo @ MySpace
Quasimondo is a Bright
Citizen of the TRansnational Republic
My other blog in german
Impressum


My family name is written Klingemann,
not Klingelmann, Klingeman, Klingaman, Kingemann,
Kindermann, Killingaman, Klingman, Klingmann, Klingonman
Klingemman, Cleangerman, Klingerman or Kleangerman

profile for Quasimondo at Stack Overflow, Q&A for professional and enthusiast programmers