ActionScript 3.0 :: BitmapData's Draw() Method Also Draws Objects With 0 Alpha
Mar 17, 2011
I am drawing a flash sprite on a BitmapData using its draw() method. This sprite has some nested objects with 0 alpha, yet the draw() method draws them on the bitmap data.
I think it has to do with the color transform I am using, but I have no idea how to change it to achieve the effect I want.
The color transform is the following:
Code:
new ColorTransform(1, 1, 1, 1, 255, 255, 255, 255);
I am using these values in order for the Bitmap to have white pixels wherever the object was, and black where there is nothing. The draw() also draws my alpha = 0 objects in white as well.
View 1 Replies
Similar Posts:
Aug 10, 2010
I have a MovieClip that has 2 images inside it:
1) An image from the FLA's library.
2) An image that is loaded dynamically from a server (read from XML file).
When I try to draw the MC into the BitmapData, I get a blank image.
Code:
ActionScript Code:
var destImg:BitmapData = new BitmapData(_root.picW,_root.picH,false);
destImg.draw( mcPicture );
View 1 Replies
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
Oct 2, 2009
I have problem when drawing transparent png image on transparent bitmapData.
code of first frame:
stop();import flash.display.Bitmap;import flash.display.BitmapData;import flash.display.BlendMode;import flash.geom.ColorTransform;import flash.geom.Matrix;
var bmd: BitmapData = new BitmapData(500, 400, true, 0);var bitmap: Bitmap = new flash.display.Bitmap(bmd);addChildAt(bitmap, 1);
[Code]...
View 1 Replies
Jan 9, 2012
I am having an issue with using BitmapData.draw(stage). I am getting the following error:
SecurityError: Error #2123: Security sandbox violation: BitmapData.draw: file:///C|/Documents%20and%20Settings/bla...bla...bla.swf cannot access null. No policy files granted access. Here is a portion of my code:
var bd:BitmapData = new BitmapData(2800, 2100); bd.draw(stage);//this is where the error happens All of the files referenced (.xml/.jpg/.swf) are located in the same local folder as the main .swf. How do I get around this error? The main objective is to print the stage using PrintJob(). I am using Flash Professional CS5.5 and publishing to Flash 10.0/10.1. Let me know if I need to supply any more info.
View 4 Replies
Dec 1, 2009
I'm making a copy of a Sprite via the BitmapData Draw method. It kind of works other than the top portion of the bitmap gets cut off (replaced with transparent pixels). It looks like it's about the same height as the Sprite's y value.
looks like this:
_________________________
| |
| TRANSPARENT PIXELS |
|_________________________|
| |
| IMAGE |
| |
| |
| |
| |
| |
| |
|_________________________|
View 5 Replies
Dec 10, 2009
The documentation says that clipRect parameter of the BitmapData.draw method sets clipping for the source.Reading this I wrote an AnimatedObject class for my potential flash game. This class draws a frame from a .png animation strip, and doesn't work with Flash scene hierarchy.
[Code]...
View 4 Replies
Aug 22, 2011
i have the following situation:
one drawing layer (graphics object with lineTo, etc.)
one png with an alpha channel (supposed to serve only as a mask)
now i want to be able to only draw lines within an area restricted by the png mask.
i am trying like this:
var bitmapData:BitmapData = new BitmapData( 320, 320 );
bitmapData.draw( drawingLayer );
bitmapData.copyChannel( maskBitmapData, new Rectangle( 0, 0, 320, 320 ), new Point( 0, 0 ), BitmapDataChannel.ALPHA, BitmapDataChannel.ALPHA );
now the borders get cut off fine, but i get a black background, since the drawing layer has an alpha between the drawn lines (and it should remain like this) and the mask bitmap has an alpha outside the shape. so naturally the mask's alpha replaces the drawing layer's.
i tried it with merge, copyPixels and also with just setting the mask property on the drawing layer (i set everything to cacheAsBitmap) but to no avail.
ADDITION:
when trying to use a mask i tried it with
<s:BitmapImage id="mask" source="@Embed(source='...')" cacheAsBitmap="true" />
and also as
[Embed("...")]
private const BodyMask:Class;
var maskBitmap:Bitmap = new BodyMask();
and assigned them to the mask property of a s:Group element (cacheAsBitmap=true) where the operations on the graphics object occured. i also tried reassigning the mask after each draw operation.
View 1 Replies
Mar 27, 2012
The code below is a simple add and save program. You press the addButton to add content to the canvas and than press the exportButton to save an image of the canvas in its current state to your desktop. This code works fine when I add circle objects to the canvas that are drawn to the canvas. The problem lies when I try to load a .png into the canvas. Once the loaded content is added to the canvas the exportButton stops working all together and no longer responds. What is causing the loaded content to break the code?
[Code]...
View 1 Replies
Jan 29, 2010
I wrote a collision detection class that works off using BitmapData.hitTest. Basically, every update, the .draw method is called and then two BitmapData's are hitTest'ed against each other to see if there is a collision.It works pretty well, however if I start rotating the source MovieClip I use for the BitmapData, the transformations don't get registered in the draw method. So what I did was pass through a Matrix in the draw method. That works. But here's the actual issue. If I output the BitmapData to a Bitmap on the stage, I see that Bitmap is, in fact, rotating, but now it's exceeding the bounds (width and height) of the BitmapData. Which is cropping / clipping the image of the source MovieClip.
UPDATE: Basically, when the Bitmap clone of the MovieClip rotates outside the positive co-ordinate space, it doesn't get drawn. It rotates outside the bounds of the BitmapData set width and height. I can multiply the bounds by 2, and then center the bitmap inside the set bounds, but then the origin point is never fixed and the object is always being moved around. Works pretty well, but makes aligning the object to any specific point impossible.Here's my isolated test code. It requires you to have a MovieClip on the stage named "iTest". I used a fairly vertical arrow shape (higher than it is wide) so I could keep track of rotations visually accentuate the clipping problem:
var rotateTimer:Timer = new Timer(10);
function rotateObject_init():void
{
[code].....
View 2 Replies
Feb 7, 2010
I'm trying to know if you can copy the pixels of many objects in one BitmapData without a huge slowdown. The slow down is made by calling the method multiple times, thus making a lot of variable declaration and disposal for the garbage collector. If someone know how to either immitate the copyPixel method or have any other way of solving this problem,
View 4 Replies
Apr 23, 2009
I have wrtitten some code that draws a couple of lines with changing alpha and width whenever the mouse is moved. I need to convert this code to AS3 so that I can use it in conjunction with some video tracking.
Code:
var speed:Number = 100;
var myNumber:Number;
var myMax:Number = 50;[code]...
View 1 Replies
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
Jul 15, 2009
I'm currently working on a flash game and I need to know how to addChild a BitmapData or draw a BitmapData to screen. If I can't than how can I give a DisplayObject my BitmapData?
View 2 Replies
Jun 30, 2011
I'm making something that requires me to draw() the youtubeplayer Giving me this pretty error:
[Code]...
View 4 Replies
Dec 15, 2009
I'm trying to do some lean blitting for an object that rotates by rotating it once at startup and capturing a BitmapData snapshot of each 5 degrees. The problem I'm having is that the draw() method of the BitmapData object is only picking up pixels in the MovieClip that are below and to the right of the registration point. If I change the MC so that the registration point is in the top left corner, I sometimes get what looks like most of the pixels, but the entire object rotates into and out of the frame, since it's rotating around the corner and not the center.
View 5 Replies
Dec 16, 2010
i have a class thats create a class with bitmapData that merge 2 IBitmapDrawable. one of them is 24*20 while the other is 16*16.i want to draw the smaller first in a bitmapData object which its width and height are 24*20 but i want to draw it in the center of the big bounds.
[Code]...
View 2 Replies
Oct 23, 2010
[URL] i want the object to fade out but in the object there's a lot of overlapping pictures and each becomes half transparent. how to make the movieclip to change the alpha as it was without objects?
[Code]....
View 2 Replies
Jan 11, 2010
I'm blitting a map onto the screen with tiles.. and the source of these tiles are BitmapData objects.I know you can change the alpha of a bitmap.. but I'm not too sure if it can be done on the BitmapData object itself.I want some tiles to have less alpha than others. Applying the alpha to the Bitmap.. makes everything on the current screen have an alpha.. but I only need one tile of it..
View 4 Replies
Nov 16, 2011
I want to extract a bitmapdata from one of the first frames of a video flv, and it works correctly in Flash debug with these statements[code]...
When i test this in [url].. not work, I've inserted trace statements before and after this, and only the first are displayed.
View 9 Replies
Aug 8, 2010
how can I draw strings onto BitmapData, is there something like Java´s Graphics.drawString()?
View 2 Replies
May 20, 2011
the problem may be a simple one but I can't figure it out. I have an image loaded into BitmapData. now I want to take text from a textinput and put it on the BitmapData. Basically it's drawing a text on the BitmapData and get the result as another BitmapData that will consist of the original BitmapData with the text drawn over it on a specified position
View 2 Replies
Jan 6, 2012
Right now I only have this code, but I'm not using BitmapData.draw(). How can I write my code using BitmapData.draw()?[code]
View 2 Replies
Nov 17, 2009
When is a Bitmap not a Bitmap ?I can apply (using Sandy) an image as a texture :
var material:BitmapMaterial = new BitmapMaterial(new myImage(1,1));
myCone.appearance = new Appearance( material );
I can trace an object and form a bitmap :
[code]......
View 1 Replies
Apr 28, 2010
I am trying to copy an image.The green stuff on the first image is a mask(which is not set, its just there to show it)Everything works fine when I dont set a mask to an image (picture 1)But when I set the mask I get picture 2.What I want is to copy a part of the image which is visible when the mask is set. I know what size the mask and image are going to be so I can calculate the size of the area which i need to copy.This is the code I am using, image has registration point in the center, thats why i use matrix.translate (not sure if its the right way).Also there is no image scaling applied (there might be later), thats why I am using matrix.scale.
Code:
var _reflectionHolder:Sprite = new Sprite();
addChild(_reflectionHolder);
_reflectionHolder.y =_targetObject.y + _targetObject.height / 2 + 10;[code]......
View 0 Replies
Mar 25, 2008
I'm building a flickr application in flex at the moment but i keep getting sandbox errors when i invoke BitmapData.draw();.After doing some google research i found that the proper policyfile needs to be loaded.i do this using: Code:Now this still doesn't resolve the issues. Upon further research i found that i need to check the policy file first using checkPolicyFile = true;
View 2 Replies
Nov 20, 2009
I'm trying to use images from wikimedia to tile a shape, but Wikimedia does not use crossdomain.xml files, so I get a security error whenever I try to do anything with BitmapData.draw().
[Code]...
View 3 Replies
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
Dec 17, 2009
I have a sprite with some objects in it which are transformed in 3D (positioned and rotated). The objects form a coneshape in such a way that the objects that make up the back are hidden.When I use that sprite as a source for the bitmapData.draw() it is drawn from another viewpoint so it seems. In my case the copy is viewed slightly from the bottom and right.
Bottomline:Does anyone know of a way to duplicate the image of a sprite which contains 3D manipulated graphics?
View 2 Replies
Apr 9, 2011
I am using NetStream.appendBytes() to play a local video (no server involved) in Adobe AIR. I would like to use BitmapData.draw() to take a picture of the video output, but I am getting this error:
Error #2123: Security sandbox violation: BitmapData.draw: cannot access null. No policy files granted access.
Here is some sample code:
package
{
import flash.display.Sprite;
import flash.filesystem.File;
[Code].....
This is only sample code use for an explanation. The error would happen when calling the getImage method while the video is playing. The error mentions a policy file not found. Since the file is loaded locally there isn't really a place to put a policy file. Is there a policy setting somewhere that needs to be set or is the BitmapData.draw feature just not available when using appendBytes?
View 5 Replies