Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / General Flash Topics / September 2008



Tip: Looking for answers? Try searching our database.

transparent image not recognized as transparent

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rritchey - 29 Sep 2008 18:47 GMT
I am loading a PNG with transparency into a UILoader.  This part works
correctly, transparency and all.

Now I need to find out the rectangle that is transparent.  I found the
getColorBoundsRect() function, and copied the UILoader.content into a
bitmapData, but when I run the getColorBoundsRect it comes back with a
Rectangle that has no width or height - IE, it finds no transparent pixels.

To test, I tried using getPixel32 on an area of the image I know is
transparent, and it comes back to tell me that the pixel alpha is 255?

Applicable code is attached.

function rightImageLoaded(evt:Event):void {
    var clBD:BitmapData = new BitmapData(735,600,true);
    clBD.draw((evt.target as UILoader).content);
    var transparentRect:Rectangle =
clBD.getColorBoundsRect(0xFF000000,0x00000000,true);
   
    trace(transparentRect);
}
rritchey - 29 Sep 2008 19:26 GMT
I am an idiot.  I forgot to set a parameter in the BitmapData constructor,
which tells it to keep transparent pixels transparent.  BitmapData defaults to
changing transparent pixels to white, which is why I was having problems.

var clBD:BitmapData = new BitmapData(735,600,true,0x00FFFFFF);
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.