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

Allen Bradley, SLC 500, 1747-M11, 32K Flash EEPROM Memory, Very Good Condition
$49.95
Allen Bradley, SLC 500, 1747-M11, 32K Flash EEPROM Memory, Very Good Condition pictureNEW IN BOX MITSUBISHI PLC FX-EEPROM-16 #FY03
$54.97
NEW IN BOX MITSUBISHI PLC FX-EEPROM-16 #FY03 pictureAutomation Direct D4-EE-2 EEPROM 32KM MEMORY CARTRIDGE DL405
$38.5
Automation Direct D4-EE-2 EEPROM 32KM MEMORY CARTRIDGE DL405 pictureNEW IN BOX MITSUBISHI PLC FX-EEPROM-4 #FY03
$24.99
NEW IN BOX MITSUBISHI PLC FX-EEPROM-4 #FY03 pictureAT24C256 Serial I2C Interface EEPROM Data Storage Module For Arduino
$1.59
AT24C256 Serial I2C Interface EEPROM Data Storage Module For Arduino picture






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