Hi all,
I’m trying to work out how to scale bitmapData images with a matrix.
I found this example (http://www.adobe.com/devnet/flash/articles/image_api_04.html) but cannot get it to work. Nothing shows up. I have a bitmap in the library with linkage of largeBitmap?
The ultimate goal is to use this method (http://www.lindsaysiu.com/dev/) to make the images fill the browser. Currently I am just loading a small JPG into MC, scaling it and then loading a larger high res version… not the best method.
Any input into this or a functional example of the matrix transformation would be greatly helpful!
Thanks:)
import flash.geom.Matrix
import flash.display.BitmapData
//attach a bitmap from the library into a bitmap object
largeBitmap=BitmapData.loadBitmap("largeBitmap")
scale=50 //scale percentage
//normzalize the scale
scale/=100
//create a new transformation matrix
scaleMatrix = new Matrix()
//scale the matrix
scaleMatrix.scale(scale,scale)
/*
If the attached bitmap is transparent, fill the bitmap with transparent pixels
otherwise fill the bitmap with white pixels
*/
fillColor=(largeBitmap.transparent) ? 0x00FFFFFF : 0xFFFFFFFF
//
scaledBitmap = new BitmapData(largeBitmap.width*scale,largeBitmap.height*scale,largeBitmap.transparent,fillColor)
scaledBitmap.draw(largeBitmap,scaledMatrix)
//free the memory that the large bitmap is using as you don't need it anymore
largeBitmap.dispose()