BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-02-2009, 08:01 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2009
Location: Belarus, Minsk
Model: none
PIN: N/A
Carrier: none
Posts: 17
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default How to set constant size of BitmapField?

Please Login to Remove!

Hi to all. I want to set my custom BitmapField to some constant size. I tried setExtent(), but my BitmapField automatically changes it size when I change it content.
Offline  
Old 12-08-2009, 07:55 PM   #2 (permalink)
New Member
 
Join Date: Dec 2009
Model: 9700
PIN: N/A
Carrier: ATT
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Setting BitmapSize

the best way to set the size of a bitmap is to use encodedimage.

I personally use a function i made SizePic....

//make your encodedimage
EncodedImage eimage;

//get encodedimage info either through bytes or from project resource

//add the bitmap
add(new BitmapField(SizePic(eimage,30,30)));


public static Bitmap SizePic (EncodedImage Resizor,int Height, int Width) {
int multH;
int multW;
int currHeight = Resizor.getHeight();
int currWidth = Resizor.getWidth();
multH= Fixed32.div(Fixed32.toFP(currHeight),Fixed32.toFP( Height));
multW = Fixed32.div(Fixed32.toFP(currWidth),Fixed32.toFP(W idth));
Resizor = Resizor.scaleImage32(multW,multH);
return Resizor.getBitmap();
}

with that you can call resizor to make the image 30x30 or declare what ever constant you want for the size
Offline  




Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.