# Bitmapdata rotating and incorrect widths

**URL:** https://forum.kirupa.com/t/bitmapdata-rotating-and-incorrect-widths/331170
**Category:** flash
**Created:** [June 6, 2013, 3:02pm UTC](https://forum.kirupa.com/t/bitmapdata-rotating-and-incorrect-widths/331170 "2013-06-06T15:02:28Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![colouredFunk](https://avatars.discourse-cdn.com/v4/letter/c/a8b319/32.png) [@colouredFunk](https://forum.kirupa.com/u/colouredFunk)
#### Post date: [June 6, 2013, 3:02pm UTC](https://forum.kirupa.com/t/bitmapdata-rotating-and-incorrect-widths/331170/1 "2013-06-06T15:02:28Z")

</div>

I have a photo that has a dynamic shape(Mask) over the top, I then want to crop the photo to the shape and resize.

Here is the code I’ve code so far

```auto

_mask.visible = false        
   _photo.mask = _mask.getShape();
 //Create a bitmapData for your mc
 var bmd:BitmapData = new BitmapData (_imageHolder.width,_imageHolder.height, true, 0xFF);
bmd.draw(_imageHolder, null, null, null, null, true);
_imageHolder.visible = false
var maskShape:Sprite = _mask.getShape();
maskShape.scaleX = maskShape.scaleY = _mask.scaleX;
maskShape.rotation = _mask.rotation;
//Create a new BitmapData for the Stripe Portion
var bmd2:BitmapData = new BitmapData(maskShape.width, maskShape.height, true, 0xFF);
            
//Copy pixels
var rect:Rectangle = new Rectangle(_mask.x-(maskShape.width/2), _mask.y-(maskShape.height/2), maskShape.width, maskShape.height)
var pt:Point = new Point(0, 0);
bmd2.copyPixels(bmd, rect, pt)

//Create a Bitmap for Bitmapdata
var croppedBitmap:Bitmap = new Bitmap(bmd2, PixelSnapping.ALWAYS);
croppedBitmap.smoothing = true;

var croppedPhoto:Photo = new Photo()
croppedPhoto.addChild(croppedBitmap);        
var maxWidth:Number = 260;
croppedPhoto.width = maxWidth;
croppedPhoto.scaleY = croppedPhoto.scaleX;
ContentManager.photo = croppedPhoto;

```

Works fine, but now I need to add the capability for when the Mask is rotated, at any angle. This seems to be a whole world of pain… when I correct the rotation of the cropped bitmap (croppedBitmap.rotation -= maskShape.rotation;)

```auto

//Create a Bitmap for Bitmapdatavar croppedBitmap:Bitmap = new Bitmap(bmd2, PixelSnapping.ALWAYS);
croppedBitmap.smoothing = true;
croppedBitmap.rotation -= maskShape.rotation;

```

I now can’t resize the image correctly…

I need to get so it resizes to a max width of 260, but now it’s resulting the cropped image being far smaller…?

Please can someone help, as I’m completely stuck…!

Thanks
