-1

How do i fill some BitmapData image with other image pattern in as 3.0? For example, i have an white image with black square at the center which would be "square:BitmapData" and the other image with little(2x2) blue circle which i would call "circle:BitmapData". I want to fill that square with this blue circles, is there any way to do this?

UPDATE

Here i found the example of what i need to do:

This is two images (left is like my square, right is like the blue circle) http://pix.samoucka.ru/img/content/graphics/thewebschedule/8/466.gif

And this is how it would look after filling http://pix.samoucka.ru/img/content/graphics/thewebschedule/8/467.gif

1 Answers1

0

You can try using copyPixels() and iterating though x and y to tile the whole thing, copyPixels() is very fast.

Or

It might be simpler to create a Sprite and use graphics.beginBitmapFill() then graphics.drawRect() with the correct size, then draw() to the BitmapData in the correct position.

If you need to determine the size and position of the black square, getColorBoundsRect() should do the job.

pseudoDust
  • 1,336
  • 1
  • 10
  • 18
  • I read your answer again and if i understand right this is what the getColorBoundsRect() is for. So i would need to use it to get the similar color rectangle area that i would need to fill, right? – user1214331 Sep 16 '12 at 16:25
  • looking at your update the example you provide is more complicated then what i thought, my suggestion will only fill rectangles. – pseudoDust Sep 16 '12 at 21:32
  • getColorBoundsRect() expects a color and returns the bounding box that encapsulates ALL the pixels of that color in the bitmap i.e. a Rectangle object containing x,y,width and height. – pseudoDust Sep 16 '12 at 21:37