Hi’ all,
I have a little problem with taking a snapshot of a loaded bitmap.
This is my script;
function captureImage():Void{
//normzalize the scale
scale /= 100
_bmp = new BitmapData( masker._width, masker._height ); // creates the bitmap of the mask's size
m = new Matrix();
m.rotate((degrees/360) * Math.PI);
m.scale(scale, scale);
m.translate( -imageloader._x, -imageloader._y); // Create the matrix used to translate the positions of the source image.
// draw the bitmapdata considering the offset of the mask
_bmp.draw(imageloader, m);
pixels = new Array();
var w:Number = _bmp.width;
var h:Number = _bmp.height;
for (var a = 0; a<=w; a++) {
for (var b = 0; b<=h; b++) {
var tmp = _bmp.getPixel(a, b).toString(16);
pixels.push(tmp);
}
}
this.attachBitmap(_bmp, 0);
//_bmp.dispose();
}
Now, the scaling works fine. Only problem is the x and y position of the imageloader. You kan move the image around by dragging the imageloader and zoom in- or out for scaling, but the x, y differs from the dragged image. See example in attachement.
fyi; trying to achieve something like elf yourself…
hope somebody can drop a hint. I think it has to be something with the translate positions.
thx.
Gr,
raack