Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Convert .png to an Array

New Here ,
Jun 01, 2014 Jun 01, 2014

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.

TOPICS
ActionScript
249
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 02, 2014 Jun 02, 2014

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 02, 2014 Jun 02, 2014
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines