0
votes

I'm trying to analyze how scaling works internally in ActionScript.

I created a small scenario:

  1. created a 2 X 2 jpg image and imported in flex. Image has 4 pixels now
  2. created a bitmap and used getPixel(x, y) and printed out values.

    Values of bitmap 2 X 2
    ╔══════════╦══════════╗
    ║ 16777215 ║ 16777215 ║
    ╠══════════╬══════════╣
    ║ 16777215 ║ 16777215 ║
    ╚══════════╩══════════╝
    
  3. Now I scaled bitmap to scaleX = 2 and printed out pixel values.

    for (var x:int =0; x < original.width; x = x+1)
    {
        for (var y:int = 0; y < original.height; y = y+1)
        {
            tempUnit = original.bitmapData.getPixel(x,y);
            outputString1 = outputString1 + tempUnit.toString() + '\t';
        }
        outputString1 = outputString1  + '\r\n';
    }
    

    Values of bitmap after scaling

    Values of bitmap
    ╔══════════╦══════════╗
    ║ 16777215 ║ 16777215 ║
    ║ 16777215 ║ 16777215 ║
    ╠══════════╬══════════╣
    ║        0 ║        0 ║
    ║        0 ║        0 ║
    ╚══════════╩══════════╝
    

What values does pixel at position (2,0), (2,1), (3,0), (3,1) take? Does it not take average values of existing pixels?

I took just these 4 pixels to analyze. I concluded that he X and Y axis unit is being changed after scaling with respect to display Object.

I'm new to ActionScript and image processing. Please point me in right direction.

1

1 Answers

3
votes

BitmapDatas do not scale when you scale a Bitmap. Look at Bitmap as a scalable wrapper for BitmapData. So, for a BitmapData you should not try getting pixels out of its bounds.