Flash :: Show A Bitmap Which Is Only A Portion Of Its BitmapData In AS3?
May 14, 2011
I am writing a screen scroller for a game I'm making. There's a BitmapData object which holds the background graphic, yet I do not want to show/render it on screen all at once.
For example, I want to show only a 500x500 section of the data but the entire BitmapData is 1000x1000. I wanted to use the scroll() method to scroll the data but my problem is that I cannot restrict how much of the BitmapData is drawn on the Bitmap. I tried setting the height/width properties of the BitmapData to 500x500 (and draw all the 1000x1000), but any data drawn beyond the boundaries I defined is not really drawn.
Another option I considered is to store a different BitmapData object which holds the entire data, and then use copyPixels() from it to the one used on the Bitmap itself, although then I cannot use scroll() and have to use different methods to achieve scrolling.
View 4 Replies
Similar Posts:
Feb 17, 2012
In pure AS3, I have a pixelbender and a large bitmap. The pixelbender is configurable with a distance parameter to affect only a small area of the bitmap. The problem is that the pixelbender is executing over the whole bitmap. What would be the best way to update only the effected region of the bitmap? Given this config:
[Code]...
View 1 Replies
Apr 20, 2011
I have two layers namely topLayer_mc and bottomLayer_mc. The actual vector drawing is drawn on the top layer and onmouseUp of the tool, a bitmap copy of the vector graphics on the top layer is taken and added as a bitmap to the bottom layer. The top layer is cleared subsequently. It is working for the pencil tool.Now I need to create an eraser tool. This is where things get tricky. In the application there is an option to save the image as png, so alpha has top be preserved. So the coventional method of draw a brush using the vector and using the draw method of bitmap will not work. Of course, on a visual level it would work if the brush drawn using the vector is to have the same color as that of the background.
What I need is to excatly erase the pixels.Now I have created a brush tool using the conventional technique and clearing is possible but what I need is to exactly erase the pixels. Is there some technique to draw this ? This is the code that I am using: I have also uploaded the swf and source code, When trying out, please draw all over the stage using the pencil (press Pencil button and start drawing)The source fla is also provided.
View 4 Replies
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
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
Sep 6, 2006
how to do the following.
I have a map, placed on the stage in its entirety.I only want to show a portion of this on screen though. Then as the mouse moves to the edge of this visble frame I want to pan over the map in that direction. just can't work out how to do it. It must be a relatively simple process but for the life of me I can't work it out.
I'm thinking maybe some kind of mask then you move the map around beneath it? I've been trying to use a couple of scrolling tile-based games tutorials but this is less complicated and I can't sceen out all the extra stuff the game tutorials are doing.
View 3 Replies
Mar 31, 2009
In Flash, the BitmapData object can be used to store bitmaps in RAM, you can later draw them to a MovieClip using the beginBitmapFill() method.
How do you load an external bitmap file (.jpg) into a BitmapData object?
View 5 Replies
Jun 16, 2010
Using Actionscript 3 is there a way to search one bitmap for the coordinates matching pixels of another bitmap?
[URL]
Somehow you would have to loop through the bigger bitmap to find and the the pixel range that matches and return those coordinates. For example the Bitmap with the "E" is 250 pixels over and 14 pixels down in the bigger bitmap.
View 2 Replies
Dec 26, 2011
So if i have a bitmap in a mc that doesnt animate (because i write directly into the bitmapdata) can i use CACHEASBITMAP?
View 3 Replies
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
Sep 16, 2009
I need to show a thumbnail of the image from my local system. So far, I am able to achieve that using Loader class and its working fine for .jpg .gif and .png extensions. But, the same is not working for neither .bmp nor .tif files. I came to know that Loader class is not capable of doing this operation. [code]...
View 4 Replies
Sep 14, 2010
I need how to cut bitmap from bitmapdata.
View 2 Replies
Sep 11, 2011
How to remove the bitmap from the holder and the bitmapData from the Flash Player memory?[code]
View 2 Replies
Aug 27, 2010
i'm writing simple image editor. I want to allow user to change contrast, brightness ect and save file as jpg. I got 2 problems.
1. I apply filters to bitmap and when I save it, it saves only original image without filters.
ActionScript Code:
var bitmapData:BitmapData = Bitmap(source_image.content).bitmapData;
var bmp:Bitmap = new Bitmap(bitmapData);
bmp.filters = combineFilters();
combineFilters function gives a set of ColorMatrixFilters to change contrast and other stuff.
2. When I encode a JPG with a as3corelibrary it makes it very slow (over 20 sec for img) and freezes app. Is there any way to aviod this?
View 0 Replies
May 8, 2009
what i need to do is basically a motion trail on a bitmap.
I want to continuously draw a bitmap onto itself while previous versions are faded into the background, similar to a smoke type effect.
View 1 Replies
Sep 23, 2011
I am trying to run the following function where car is a movieclip:
[Code]....
View 1 Replies
Sep 29, 2010
In Flex, how does one hook into a bitmap or bitmapdata variable so that a function is notified whenever the bitmap's data has changed (pixel has changed, or filter's been added)?
There must be a way to do it, because I can bind an mx:Image to a bitmap via the 'source' attribute, and the displayed image updates all the time when a I modify the bitmap. How does flex do it? Does it blindly redraw the bitmap at every frame, or is it smart and only redraws when the bitmap changes? If so, how does it know when the bitmap changes?
View 1 Replies
Oct 29, 2008
I want to be able to crop an image based on what is viewable through the mask and then saved that cropped image out to a new file. I'm not exactly sure how to do this though
View 3 Replies
Jun 28, 2007
I've been looking for a solution for hours now. I have a movieclip which contains an image. Created by doing: put image on stage, convert to symbol, movieclip type, ok.I'd like to extract this bitmap because I want to use (somewhere else): graphics.begintBitmapFill(); but this method needs a BitmapData object and not a movieclip to create a repeating background (in my case).
So: how do I extract the Bitmap or the Bitmap data from a MovieClip?mind that attaching BitmapData as a base class to this symbol is NOT AN OPTION
View 11 Replies
Jul 16, 2010
What i want to do is get a png from my library load it into bitmapData then into bitmap then onto the stage.I don't even have enough success here yet to have code to post. Please for the LOVE of Mike!
View 5 Replies
Jun 1, 2011
I have the following code
///Get BitmapData from library in SWC
var ClassReference:Class = getDefinitionByName(products[i].producticon+"Data") as Class;
// Create new BitmapData Instance From it
[Code]....
I get null in the trace. How do I make a dynamic class that I can refer to for this bitmap similar to how your reference a class from and embedded media?
View 1 Replies
Dec 22, 2009
I have a class that loads an image and offers you the ability to have it in a bitmap or bitmap data object available after the image has loaded. But when I try this:
[Code]....
View 2 Replies
Feb 17, 2010
I have a small bitmap, and it's one that's going to be scaled to be much larger then added to another bitmap. So I have the bitmap and I changed to width to make it larger, then when I use copyPixels to place this bitmap onto the main bitmap the image added is the original bitmap, not with the width changed. How can I make it reflect the changes?
View 3 Replies
Mar 1, 2010
1: I upload an image
2: Without altering it,I make a copy of it and use it display to users in resized format
note: I won't display the original image.
3:Now when user deletes the resized image,i need to delete the image loaded as bitmap i.e. the original image which i won't be displaying
For that I used bitmap.bitmapData.dispose() method.But,it doesn't free up the memory taken by the bitmap.For instance at initial state the memory usage is 58 Mb and upon loading 3 images the size increases to 87 Mb.And when I delete all the images the size decreases to 81 MB only.
View 6 Replies
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
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
Jun 6, 2010
This is my scenario
1: I upload an image
2: Without altering it,I make a copy of it and use it display to users in resized format
note: I won't display the original image.
3:Now when user deletes the resized image,i need to delete the image loaded as bitmap i.e. the original image which i won't be displaying
For that I used bitmap.bitmapData.dispose() method.But,it doesn't free up the memory taken by the bitmap.For instance at initial state the memory usage is 58 Mb and upon loading 3 images the size increases to 87 Mb.And when I delete all the images the size decreases to 81 MB only.I feel the loaded bitmap is not completely removed.
View 9 Replies
Jan 29, 2007
I've started getting to grips with using the BitmapData class and a Transformation Matrix in the hope that I can start making some interesting image effects. However, at the moment Im having trouble figuring out how to shift the newly created bitmap so that any scale transformations are applied from the center rather than the top left corner. See here for example: [URL] The flower on the left is the original, the flower on the right is the new image created using "bitmapData.draw()". It has been scaled up to twice the size, but I want this to happen from the center of the image.
[Code]...
View 5 Replies
Jan 21, 2007
Ive created a empty movie clip then tied it in to a bitmap that exists in the library called "red" (I made it available for export). The bitmap does not show at all, when run. I don't want to use the function attachMovie.
var movieClipHandle:MovieClip = this.createEmptyMovieClip("picture1_mc",this.getNe xtHighestDepth());
var myBitmapData1:BitmapData = BitmapData.loadBitmap("red");
[code].....
View 1 Replies
May 30, 2011
I'm doing an AIR/FLASH PROJECTOR random bitmap application. The bitmaps(pictures) are stored in a server. In my application, there are 1 button 'ROLL', which will toggle the randomly picking of butmap and show them out.
Q1:Currently, I'm able to retrieve the picture from server when I clicked the 'ROLL' button and show it on flash stage, but how do I set a limit to stop the same bitmap from showing up again and again on my next roll? (it should only show up 1 time)
Q2:The other issue that I dont know how to create an animation every 0.5second, changing the picture to another picture (trying to show the thrilling feeling).For example, when I clicked the ROLL button, the application will randomly pick 1 picture and some other pictures to do a simple animation. The picture will keep changing at an interval of 0.1seconds or so, and will slow down to interval of 0.2seconds, and slow down again and again. Finally, after doing that animation for like 5seconds or so, the "randomly picked picture" will show up. And this randomly picked picture will not show up again at the next roll.
View 3 Replies