BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-10-2007, 04:27 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8800
PIN: N/A
Carrier: GPRS
Posts: 68
Post Thanks: 0
Thanked 0 Times in 0 Posts
Smile A problem of draw image

Please Login to Remove!

Hi,everyone:
I'm learning development on JDE 4.1.0, and I have a problem in drawing a image! The image is from Internet through a url and it's about 800*600 in the JPG format.
first:
image = EncodedImage.createEncodedImage(imageData, 0, imageData.length );
I create the image according the imageData received from Net in bytes;

then:
graphics.drawImage( x, y, width, height, this.image, 0, v_CurrentZoomX, v_CurrentZoomY);
I use this sentence to draw the image!

But there is a problem, the image is too big and can not be put in the screen. I can see that there is only one part of image in the screen .I search for
drawImage method in RIM and it says the function will cut dowm the overplus part.
I do not find some other function to zoom out the image , so can anybody give me some ideas to do it?
or I should write the a new class to realize the ability of zonnm out?
Thank you very much !
Offline  
Old 07-10-2007, 05:39 AM   #2 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

mdwheaton over on the official bberry dev forum posted this code that works well, i've used it before:

EncodedImage bitmap = null;
String path = "/classpath/to/image.png";
InputStream in = ThisClass.class.getResourceAsStream(path);
byte[] data = new byte[in.available()];
in.read(data);
bitmap = EncodedImage.createEncodedImage(data, 0, data.length);

int divisor = Fixed32.toFP(100);

/**
* Change this number, < 100 makes the image bigger by
* percentage. i.e. 90 makes the image 110% normal size.
* By increasing, you will reduce the image size,
* e.g. 110 makes the image 90% normal size.
*/
int multiplier = Fixed32.toFP(110);

int fixedX = Fixed32.toFP(1);
/** First, divide the image scale by 100. */
fixedX = Fixed32.div(fixedX,divisor);
/** Now, multiply the image scale by the multiplier. */
fixedX = Fixed32.mul(fixedX,multiplier);

int fixedY = Fixed32.toFP(1);
fixedY = Fixed32.div(fixedY,divisor);
fixedY = Fixed32.mul(fixedY,multiplier);

bitmap = bitmap.scaleImage32(fixedX,fixedY);
in.close();

BitmapField bmp = new BitmapField();
bmp.setImage(bitmap);
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Lot Of 5 NTDU92, Nortel I2004 Internet Telephone Voip Phones, 2x10/100Base-TX
$37.99
Lot Of 5 NTDU92, Nortel I2004 Internet Telephone Voip Phones, 2x10/100Base-TX pictureLot of 8 Aastra VoIP IP PoE Business Phone 4x 6755i 2x 55i 6735i 53i - Parts }
$113.69
Lot of 8 Aastra VoIP IP PoE Business Phone 4x 6755i 2x 55i  6735i 53i - Parts } picture(2) Shoretel IP230G IP VoIP Gigabit Small Business Display Phones (Silver) SAVE$
$125.0
(2) Shoretel IP230G IP VoIP Gigabit Small Business Display Phones (Silver) SAVE$ pictureOne lot of 4 CISCO Systems 7960G VOIP IP Business Telephone Gray WORKING
$34.99
One lot of 4 CISCO Systems 7960G VOIP IP Business Telephone Gray WORKING pictureVoIP Phones Zultys ZIP 53i (Aastra 6753i) Used Phones, Set of (7) Seven
$105.0
VoIP Phones Zultys ZIP 53i  (Aastra 6753i)   Used Phones, Set of (7) Seven picture






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