Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
Posts: 172
Registered: ‎01-17-2011
My Device: 9500 series
My Carrier: Airtel

Resize image data size

Hello Friends

 

I am creating an application in playbook using adobe air, 

in which i need to resize the image size

like i am having 1024 x 768 resolution image size in device having suppose 100kB size

now i want to resize it to some resolution like 200x 150, which should reflact to image itself, like on seeing this image properties in device, its size should be less.

Is it possible to do by code

Please help me..

Thanks in advance

 

Shashank

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Resize image data size

If you just want to resize an image (see Image class), you can set the width and height to the desired size. If you want to keep the proportions, then you have to do some math to determine the major axis and percent needed. However, the memory of the image will still remain the same. There are calls to copy bits after the resize and then use that for display which I think is want you are asking. In other words, there are plenty of APIs to manipulate the image (bitmap data) to what you are looking for.
Developer
Posts: 172
Registered: ‎01-17-2011
My Device: 9500 series
My Carrier: Airtel

Re: Resize image data size

Hello Jtegen

 

Actually i want to upload image, so i need to resize the memory size of image by which i can send it in less data uses of network, because currently i am having 2452 x 1476 resolution but i need to display less resolution of it, which i am able to set it by using image class and its stretch property, but in case of uploading memory size is still same, so i want to reduce the image size, by which it can upload fast. Like using adobe photoshop we change the resolution of image and its reduce the data size too, exactly i also want to do this by code..

Please help me out from this problem

Thanks.

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Resize image data size

[ Edited ]

Look at the JPEG encoder class where you can specify "quality" (0-100) that reduces the image memory/file size for upload. For example:

var jpg_encoder : JPEGEncoder = new JPEGEncoder( 100 );
var img : ImageSnapshot = ImageSnapshot.captureImage( original_img, 0, jpg_encoder );

Developer
Posts: 172
Registered: ‎01-17-2011
My Device: 9500 series
My Carrier: Airtel

Re: Resize image data size

Hello i have read about it.

here JPEGEncoder is an encoder which is used to encode, i am familiar with this class, in which we have a encode method which is used to provide byte array , but it takes min 1-2 sec to respond in device.

Here imagesnapshot method captureImage() method returns ImageSnapshot object,

Please provide me code snippet by which i can understand it easily , i will very thankful for you, as i need to implement it urgently.

Waiting for your response.

Thanks

 

 

New Contributor
Posts: 2
Registered: ‎10-05-2011
My Device: Blackberry bold 1
My Carrier: what

Re: Resize image data size

Guys sorry to inturrupt but how can i post a thread ? i have a problem with my bb when i'm upgrading my bbm .. Its giving me "Your device does not have enough storage space to complete the download. To continue downloading, delete the language that you do not use (i only have english) or delete an item from my world. Refer to the Help for more

Developer
Posts: 172
Registered: ‎01-17-2011
My Device: 9500 series
My Carrier: Airtel

Re: Resize image data size

Well pretty strange..

you will get this issue when your smartphone memory is full and there is no space to install this application.

dont feel if you SD card you can install it. you need to have enough internal memory space to install application.

that i feel so

New Contributor
Posts: 2
Registered: ‎10-05-2011
My Device: Blackberry bold 1
My Carrier: what

Re: Resize image data size

I deletet from both memory, same thing. How can i post a thread ?

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Resize image data size

Press the "New Message" button on the top message board.
Developer
Posts: 439
Registered: ‎10-25-2010
My Device: Not Specified

Re: Resize image data size


shaan_softwaredvlpr wrote:

memory size is still same, so i want to reduce the image size, by which it can upload fast. Like using adobe photoshop we change the resolution of image and its reduce the data size too, exactly i also want to do this by code..



You need to draw() it to a new bitmapData object, using a transformation matrix.

 

ie, an image with half the size:

var smallBitmap:BitmapData = new BitmapData(largeBitmap.width/2, largeBitmap.height/2, true, 0x0);

var m:Matrix = new Matrix();

m.scale(.5,.5);

smallBitmap.draw(largeBitmap, m);

 

Something like that Smiley Happy

 

Btw, googling "as3 resize bitmapData" will not take you too long to find a solution... one of the nice things about working in flash.