Skip to main content
Participant
June 1, 2014
Question

Convert .png to an Array

  • June 1, 2014
  • 2 replies
  • 281 views

Hello,

I am trying to import a .png file and break it up into an array of 10x10 pixel blocks, while ignoring the alphas. I have no sample code to analyze, as I am not sure how to begin. Any help would be appreciated. Cheers.

This topic is closed to new replies. Start a new post to keep the conversation going.

2 replies

kglad
Community Expert
Community Expert
June 2, 2014

use the bitmapdata class'es draw method to create your 10x10 blocks.  the draw method has a clip rectangle property ideal for you.

Amy Blankenship
Legend
June 2, 2014

FWIW, copypixels is faster than draw(). I'd use draw() to get the entire thing out of the library asset, then copyPixels() to draw each one. However, you may want to rethink if you actually need to store each 10x10 area. It might work just as well to know where they are, then use copyPixels to draw the one you want when you need it.

To find example code, search on Actionscript Blitting or Flash Blitting.