ActionScript 3.0 :: Use The BitmapData.setPixels Method To Set Certain Pixels In The Bitmap Transparent?

May 2, 2009

I am trying to use the bitmapData.setPixels method to set certain pixels in the bitmap transparent.But no matter what I do, it always seems to set the pixel(s) black (non-transparent).Here is my code:

[AS]
bmpd = new ImageFromLibrary(0, 0);
bmpd.setPixel(0, 0, 0x00000000);
[/AS]

why its not setting the pixel(s) transparent?

View 4 Replies


Similar Posts:


Actionscript 3 :: Use The Method SetPixels(rectangle, ByteArray) Of BitmapData In Adobe Flex

Feb 3, 2011

Error #2030: End of file was encountered.

This method is not working

I am using it like this

var ba:ByteArray = new ByteArray();
ba = bmd.getPixels(bmd.rect);
bmd.setPixels(srcRect, ba);
bm.bitmapData = bmd;
img.source = bm;

View 1 Replies

ActionScript 3.0 :: Knowing If A BitmapData Contains Transparent Pixels?

May 13, 2010

I have a list of images, and without scanning through each pixel in each image, I want to find out if the image contains transparency (at least one non-opaque pixel).Is there a shortcut to do this (like a property of bitmapData object) rather than looping through the pixels?

View 5 Replies

ActionScript 3.0 :: Draw Opaque Pixels On A Transparent Bitmapdata Background?

Oct 28, 2010

im trying to draw opaque pixels on a transparent bitmapdata background

heres the ex:

ActionScript Code:
//TRANSPARENT BACKGROUND
var _pixelColor:uint = 0x9998002E;
var _bmpd:BitmapData = new BitmapData(4, 7, true, 0x00333333);

[Code].....

This example paints 2 arrows, the first is using the transparent background, and the second is using an opaque background on the BitmapData.

What I'm trying to achieve is to paint the pixels of the arrow completely opaque on the transparent background. But as you can see, the pixel is at 99% of its opacity (var _pixelColor:uint = 0x9998002E) How can I paint 100% opaque pixels on a transparent BitmapData "canvas"?

View 1 Replies

ActionScript 3.0 ::make All White Pixels In Bitmap Transparent?

Jul 29, 2008

i want to make all white pixels in my Bitmap transparent. i found the treshold-method and try to use it:

Code:
var pt:Point = new Point(0, 0);
var rect:Rectangle = new Rectangle(0, 0, 2000, 2000);
var threshold:uint = 0x00FFFFFF; // all white Pixels

[Code]....

View 3 Replies

As3 :: Flex - Handling Inverted Pixels In BitmapData And Bitmap Class

Mar 29, 2010

I am using bitmapData and bitmap classes to render a mouse cursor on the display screen. The bitmapData consists of an area whose colors should be inverted according to the background color. This is a very basic thing which could be observed with text cursor(the vertical line with two small horizontals on top and bottom), when moved over the text area. want to be able to do the same with the pixels in my bitmapData, is there a way to find out the background color effectively and invert the color values? In this process i will be redrawing the whole pixels, is there any other efficient way to do that ?

View 1 Replies

ActionScript 3.0 :: BitmapData - SetPixels / SetVector Difficulties?

Dec 22, 2010

I'm trying to get my head round bitmapData and everything you can do with it. I'm using pure AS3 at the moment.I've been playing with some Perlin noise examples - worked ok - and tried writing another image (png) onto the bitmapdata.The new image is EMBEDed in the as3 code:

Code:
[Embed(source='icon.png')]
private var ImageClass:Class;
private var img:Bitmap = new ImageClass();

I write the perlin noise to the BitmapData thus:

Code:
var bmd:BitmapData = new BitmapData(200, 200, true, 0x00000000);
bmd.perlinNoise(baseX, baseY, octaves, seed, stitch, fractal, channels, grayscale, offsets);
var bm:Bitmap = new Bitmap(bmd);

View 2 Replies

Flash :: Find The Size Of The Area In A Bitmap Which Has Been Filled Using The Bitmapdata.floodfill Method?

Sep 27, 2011

I am using the floodfill method to colour-in sections of a bitmap image. That part is easy enough but the issue comes in with the way I am adding an effect to the colour fill routine.

To add the effect, first a copy of the bitmap data is created and floodfill is used on that instead of the original bitmap. Then the bitmapdata.compare method is used to set the alpha value of everything apart from the filled-in section to 0 and the result is saved in another bitmapdata. After that, a 1 px radius circle sprite is added to the stage and is being tweened to the image dimensions and its mask is set to the sprite which contains the result of the compare operation.

This works perfectly except for the fact that the fill sprite has to be tweened to the complete image dimensions irrespective of how small the area is being coloured-in since I am not able to find a way to get the dimensions of the fill area. I am doing an bitmap image update at the end of the tween and I have to disable user interaction till the tween is complete to avoid the errors which come in if another fill-in operation is started before the base image has been updated. If I could somehow get the dimensions of the fill area then the time during which I have to disable the user interaction will go down considerably.

View 3 Replies

Actionscript 3 :: Quickly Rotate The Pixels That Make Up BitmapData Without Using BitmapData.draw()?

Dec 29, 2011

I've been using BitmapData.copyPixels() to draw graphics onto a canvas (Bitmap).I need to rotate the resulting graphics without the use of draw() because it's vastly slower.How can I rotate the target graphic? I'm assuming that there might be a formula or library that I can use which will first reorganize the pixels that make up a graphic based on an origin (point) and radians.I'm pretty certain that I'm not capable of creating such logic, so if there are any known libraries that do this, that would be awesome.I'd like to achieve something similar to XNA's SpriteBatch.Draw() method, which accepts rotation as its 5th argument.

View 3 Replies

ActionScript 3.0 :: Remove Transparent Pixels From Transparent Png?

Feb 27, 2010

I am creating a map in flash cs4 with all the countries on it. I used photoshop for creating the map and separated countries. Now I imported all pngs in Flash and I want to give Mouse CLICK event and Mouse Hover on all pngs, but as the transparent pixels are overlapping the other states, it is getting difficult. So, I converted all pngs in movieclips and now then I broke up pngs. Now I want to delete all pixels having alpha 0 using eraser tool, as per the borders. And I have to do it manually for individual countries. So is there a way to remove transparent pixels from the bitmap data?

View 2 Replies

ActionScript 3.0 :: BitmapData Draw() Method - Draw The Bitmap On The Stage At Design Time?

Mar 18, 2009

I am using the draw() method of the BitmapData to encode a jpeg of part of the image. Now this should be easy enough given the object I want to draw to the bitmap is on the stage at design time so I know its location and dimetions exactly! Heres the code I have in place.

Code:
var myBitmapSource:BitmapData = new BitmapData ( street.width, street.height, false, 0x333333);
myBitmapSource.draw(street, null, null, null, new Rectangle( 96, 5, 571, 450 ), true );

I know for a FACT that no part of the street clip I am drawing out is in negative space, and it's registration is (0,0). However, it cuts off A lot of the top of my image. y=5 in the above rectangle is where I need the top to be, but it cuts the top off of the image... even if I change it to 0, it has no effect.

View 2 Replies

ActionScript 3.0 :: Access The Newly Created Bitmap Data To Access The Method CacheAsBitmap.bitmapdata.dispose() ?

Oct 22, 2010

So, you have a sprite, you draw some graphics, you set cacheasbitmap=true... I can't seem to access the newly created bitmap data, to access the dispose() method.

[Code]...

View 6 Replies

Actionscript 3 :: Draw Transparent Graphics Onto Transparent BitmapData?

Feb 5, 2012

I'm trying to draw PNGs onto BitmapData that is transparent.

I create my BitmapData like this (using ARGB for the color):

new BitmapData(width, height, true, 0x00000000);

And clean it by using the same ARGB value:

bitmapData.fillRect(bitmapData.rect, 0x00000000);

When I use copyPixels() to draw graphics onto the cleaned BitmapData, I get this result:

If I don't use ARGB for the BitmapData color, it works fine:

But I have to specify a solid fillColor, meaning I can't render what's behind the Bitmap.

How can I make my BitmapData transparent, but not have the above occur?

View 1 Replies

ActionScript 3.0 :: Bitmapdata.hitTest - Bitmap 'emptyBitmap' With Bitmap Data Created

Feb 3, 2009

I'm cutting my teeth in actionscript 3 on a game that has a character running through a world. So, I have set up my Hit Testing by using the bitmap data hit test method, since I figured my world is going to be destructible - it'd be nice to update the level and then redraw it and have the character interact with the new change. (That works beautifully) I am however; a bit confused as to how I have my hit Testing set up. I've been messing around with it, and it works for now - but I'm not sure why.. currently, I have a character set up by using a class I built and using a series of animations I created. So, this character has a walking and falling animation, etc. This is a movie clip.

Then there's a bitmap 'emptyBitmap' with bitmap data created - however; I never really added this as a child to the character. This is sized to the dimensions of my character. My level is created as a movielip, then it's drawn to a bitmap - when the level movieclip is changed, the bitmap redraws, and that's how this updates.

[Code]....

View 1 Replies

ActionScript 3.0 :: Use The BitmapData Property Of A Bitmap And Pass It To The Constructor Of A New Bitmap Object?

Aug 20, 2009

I know the topic of "duplicating" movieclips is a hot issue with the new virtual machine. Luckily, I understand the implications. I only am [currently] interested in duplicating a Bitmap. See, I load an image from an URL using 'flash.display.Loader.load', which is a non-blocking operation in Flash Player.However,I may use multiple copies of the loaded image (which is reported to be a Bitmap, naturally) in the display list at the same time.Hence, I naturally do not want to load the image from an URL every time, because I don't want to wait for a non-blocking call to complete. Nor do I need to - I mean one copy is already loaded, so it should be possible to just "duplicate" it, right?

My idea is to do use the bitmapData property of a Bitmap and pass it to the constructor of a new Bitmap object. I have not tried the following in action, but I want to hear whether any of you did and if the following would not work, what would:

Code:

var original_bitmap: Bitmap;
var copy_of_original_bitmap: Bitmap = new Bitmap(original_bitmap.bitmapData);

LiveDocs mention that the BitmapData being passed to a Bitmap constructor is "being referenced", which to me might suggest it cannot be used twice? There is also the BitmapData::clone() method, which I am not sure is applicable here or not.I know this is a lot of talk instead of just trying this out, but I test so much Flash Player code daily just to see "what works" (which should be documented instead by Adobe),

View 4 Replies

ActionScript 3.0 :: Getting BitmapData With Masking Pixels?

Mar 9, 2011

I'm trying to create a BitmapData object from a movie clip, but I need to also get the pixel data in a layer that has been set as a mask in the authoring environment. All I'm getting is the masked in pixels, but I also need the mask itself, and I'm can't seem to find a way to do it.

View 2 Replies

ActionScript 3.0 :: Part Of The Pixels Are Transparent - Don't Be Clickable

Sep 13, 2009

I want to create a SimpleButton that has some  PNG/GIF graphics as the down/up states. Part of the pixels are transparent and I don't want them to be clickable, is that doable?

View 9 Replies

Flash :: Set CopyPixels To Ignore Transparent Pixels?

Mar 17, 2011

I have a BitmapData object with transparency (the sourceBitmapData parameter). Every time I use copyPixels() to copy it onto another BitmapData object the transparent pixels replace whatever is beneath them. I would like the copyPixels() function to simply ignore these fully transparent pixels (0x00) and NOT copy themBTW, I've tried setting the alphaMerge to true but that doesn't solve the issue - the whole source object just goes black and ignores ALL transparency.EDIT:

Here are the code snippets;
var b:UIComponent = new UIComponent();
b.graphics.beginFill(color, opacity);

[code].....

View 3 Replies

Flex :: Color All Pixels That Are NOT Transparent To Black?

Aug 5, 2011

I am using ColorMatixFilter on an Image in Flex. I am really close to getting want I need out of the filter.Basically any PNG file the user uploads I want all pixels that are not transparent to be colored black. I have a function that sets the "brightness" already so I just through a really large negative number at it like -1000 and it does the job but the problem is any pixels that have any alpha to them, say 0.9 or below all end up being white when I encode my PNG file on the server later.

[Code]...

I would like all pixels to be solid black unless the pixel is completely transparent and not sure how to tweak the values to get that out of it.

View 1 Replies

Flash :: Trim Away The Transparent Pixels Of The Image?

Nov 16, 2011

I have a Flash fla file that contains a whole lot of images. The majority of each image is composed of transparent pixels with a visual object in there somewhere. Each image at the moment is at {x:0, y:0}.I want to trim away the transparent pixels of the image down to a minimum bounding box, but keep the object at the same global position. This requires shifting the trimmed image to the global position of the object in the untrimmed image.This is not so much a problem, but the fact that the images are all contained in a fla is the problem. The options I see at the moment are:

investigate JSFL, the Bitmap object has a getPixels, this in combination with a selection and delete operation could work save the fla to xfl and enumerate the images and associated xml with something like Ruby + image processing lib

Questions: Does anyone know upfront if this operation is possible in JSFL? Have anyone done much automated processing of xfl files? Is there an off the shelf image processor that can perform this trimming operation?

View 3 Replies

ActionScript 3.0 :: BitMaps - Remove Transparent Pixels?

Jan 28, 2009

Iv created an app in work which needs a rubber. I basicly have a tool to draw line (paint/pencil). This draws over the entire stage area, including over buttons and interactive mc's. Once i draw the line i then want to be able to erase bit of it.

To this end iv made an eraser tool, which works well. I turn the line into a bitmap, then turn the eraser line into a bitmap and use BlendMode.ERASE to erase one from the other. My problem is, because when creating the bitmatdata i have to create a rectangular shape, the area created then means that i cant access any of the buttons underneath.

here is my code:

ActionScript Code:
//line array is an area of all the line objects which are currently live on stage.
for(var i=0; i<lineAr.length; i++){

[code]....

The way i see it i need to remove the transparent pixels from delBitMap once the erase has been done.

View 2 Replies

ActionScript 2.0 :: HitTest That Ignores Transparent Pixels?

Jun 17, 2009

Is there anyway I can do a hittest that ignores transparent pixels? If so how would I do it.

View 2 Replies

ActionScript 2.0 :: Copypixel Not Replace Transparent Pixels?

Aug 4, 2009

I'm trying to use copypixel to copy an image and paste it onto an existing bitmap. However, the image I'm trying to copy has transparent pixels so when CopyPixel's pastes the image onto my existing bitmap, the pixels already on the image is replaced by the transparent pixels from my image.

How can I make it so CopyPixel will only paste all pixels besides the transparent ones onto my bitmap?

View 2 Replies

ActionScript 3.0 :: BitmapData - Pixels Must Have Specified Gray Color Value

Aug 1, 2009

I need to create, from a given Bitmap/BitmapData of a PNG file which has transparent and semitransparent pixels, another BitmapData which is a copy of it, but all the pixels (well, the pixels that are not alpha 0% actually) must have a specified grey color value (0xdddddd).

View 2 Replies

Actionscript 3 :: Remove All Black Pixels From BitmapData?

Apr 19, 2010

Let say I have a BitmapData with different pixels representing an object, and some black pixels around it that I want to remove.I would like to obtain a new BitmapData, with width and height of the object represented by non-black pixels.For example, let say I have a BitmapData 400x400px, but the object represented by non-black pixels occupies the rect: x=100, y=100, width=200, height=200. I want to get new BitmapData representing that rect, all black pixels should be removed. Of course, i have no coordinates for that rectangle, i need somehow to make difference between a full black bitmapdata and the original one, and construct a new bitmapdata (different width and height).

View 1 Replies

Actionscript 3 :: Removing Pixels Of One Color From A Bitmapdata?

Feb 24, 2012

I have a map (map of a mall, top view) with some colors. Iīm removing the part for walking of the map, which has a type of color (say 0xcccccc).

I got all the 0xcccccc color pixels removed (setted to another color), but it seems to remain a bit of gray at the walking part.

The color of that bit itīs close to 0xcccccc. It looks like flash not succeeded while removing the walking part. But instead, leaved some parts (like borders or something) on the bitmapdata.

Iīve tried to remove by script, by picking the colors remained on the bitmap, but the loop doesnīt find these colors.

View 1 Replies

ActionScript 2.0 :: BitmapData Clear Pixels Or Set Alpha

Feb 26, 2008

What I have setup right now is one movieClip that is being used to be drawn into a BitmapData object. That bitmapData object is being drawn on the enterFrame and I am needing to clear it so it doesnt have the previous enterFrames information still stored in it, then once it is clear draw the current information. Is there a simple way to clear or erase all the pixel information in the BitmapData object?

If there is a way to set the alpha of the pixels I would really like to know how that is done as well. However, I want to change the alpha level of the entire BitmapData object, not just a few pixels.

View 2 Replies

Actionscript 3 :: BitmapData Copy Pixels Half Pixel?

Feb 17, 2012

Having trouble trying to scroll BitmapData on a half pixel here is my original code

var speed:Number = 1;
_bitmapData.copyPixels(_backgroundParallax, _screenRect, _zeroPoint, null, null, true);
_backgroundParallax.copyPixels(_backgroundParallax, new Rectangle(0, 0, speed, _backgroundParallax.height), new Point(_backgroundParallax.width-speed,0), null, null, false);
_backgroundParallax.scroll( (speed*-1) , 0);

which works until i change the var speed to .5, which is because .scroll method is expecting int's so i replicated what scroll is doing to try and allow .5 pixels

[Code]...

View 1 Replies

Flash :: Narrow A Rectangle Within A Sprite To Exclude Transparent Pixels?

Oct 2, 2011

I have a Sprite that contains opaque objects surrounded by transparent pixels. I also have a Rectangle that represents a part of the Sprite that I want to render using BitmapData.draw(). The problem is that the Rectangle that I obtained also contains transparent parts. How can I narrow the Rectangle to only include the opaque parts and ignore the transparent surroundings?

kapep's answer is just what I want to do, but the problem is that the source is a Sprite, not a BitmapData object, and I don't have getColorBoundsRect() on a Sprite.

View 2 Replies

ActionScript 3.0 :: Trim - Width And Height Are Not Effected By Transparent Pixels?

Feb 23, 2009

Is there a way to trim a bitmap so that the width and height are not effected by transparent pixels?

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved