# Scaling bitmapData images?

**URL:** https://forum.kirupa.com/t/scaling-bitmapdata-images/257894
**Category:** flash
**Created:** [April 18, 2008, 1:33am UTC](https://forum.kirupa.com/t/scaling-bitmapdata-images/257894 "2008-04-18T01:33:41Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![wu\_tang1](https://avatars.discourse-cdn.com/v4/letter/w/dfb087/32.png) [@wu\_tang1](https://forum.kirupa.com/u/wu_tang1)
#### Post date: [April 18, 2008, 1:33am UTC](https://forum.kirupa.com/t/scaling-bitmapdata-images/257894/1 "2008-04-18T01:33:41Z")

</div>

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](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/](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:)

```auto
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()

```
