Select to view content in your preferred language

ImageSnashop size 800 x 600

1114
5
04-12-2010 08:52 AM
AlexanderMena
Deactivated User
Hi,

How I can get ImageSnapshot of size 800 x 600 ?

I have the next code and I don't works.

ImageSnapshot.MAX_BITMAP_DIMENSION = 800;
var imageSnapshot:ImageSnapshot = ImageSnapshot.captureImage(map,0,jpgEnc);
imageSnapshot = new ImageSnapshot(800,600,imageSnapshot.data);

thank a lot your help.

Alexander Mena.
Tags (2)
0 Kudos
5 Replies
PrashanthSukumaran
Emerging Contributor
Hi Alexander,

Are you trying to scale it? 

Thanks
Prashanth Sukumaran
0 Kudos
AlexanderMena
Deactivated User
Yes I do. I trying of get a image with size 800 x 600 pixels. The ImageSnashop class  returns a image with size 1020 x 567 pixels.
0 Kudos
PrashanthSukumaran
Emerging Contributor
Hi Alexander,

Looking at the ImageSnapshot.as code i think the solution provide below should work.

The captureImage is basically trying to scale the image based on the screen DPI.   Looks like Flash is returning 72 dpi always.  Since you are doing this
var imageSnapshot:ImageSnapshot = ImageSnapshot.captureImage(map,0,jpgEnc);  

The second parameter Zero means zero dpi the scale is 1 always for you.  ie.,
Matrix(1,0,0,1).  So ImageSnapshot.captureimage it is returning the same size as the displayobject. 

Doing this will not have any effect.
imageSnapshot = new ImageSnapshot(800,600,imageSnapshot.data);


So in your case it would be  Matrix(1020/800, 0, 0, 567/600).  ie., Matrix(1.275, 0, 0, 0.945).  Since the scale is not the same, i don't think you will be able to use the captureImage.

Instead you should try to use  ImageSnapshot.captureBitmapData where you will pass your custom Matrix yourself.

Is this too much code.....
                var width:int;
                var height:int;
                var bytes:ByteArray;
                var matrix:Matrix = new Matrix(1.275, 0, 0, 0.945)
                var data:BitmapData = ImageSnapshot.captureBitmapData(map, matrix);
                var bitmap:Bitmap = new Bitmap(data);
                width = bitmap.width;
                height = bitmap.height;
                bytes = encoder.encode(data);  // encoder is the JPEGEncoder you want to use.  I think by default the encoding is done in PNG.

                This bytes can be saved to the backend or you could create another imagesnapshot object to encode the images as  base64.


Thanks
Prashanth Sukumaran

NOTE:  Check the ImageSnapshot.as code that comes with Flex SDK.  It is really easy to understand what i am saying.
If you have installed 3.5 sdk you will find it in this folder (sdks\3.5.0\frameworks\projects\framework\src\mx\graphics\ImageSnaopshot.as)
0 Kudos
AlexanderMena
Deactivated User
Thank Prashanth, this is work fine. Do not use it because the image obtained is of low quality.

Alexander Mena.
0 Kudos
PrashanthSukumaran
Emerging Contributor
Thank Prashanth, this is work fine. Do not use it because the image obtained is of low quality.

Alexander Mena.


Try PNG, you should see a good quality output. JPEG is lossy compression and would not be good.
0 Kudos