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

Java Development

Reply
New Contributor
jgpark
Posts: 9
Registered: ‎07-27-2010
My Device: Not Specified

Re: displaying tiff images

It was a nice try, but it still doesn't work. Does anyone know the reason for this IllegalArgumentException? (API 4.5.0 net.rim.device.api.ui.Graphics: line 1325)

 

I guess it's safe to assume their tiff support is broken. This isn't the first time their API has sent me on a wild goose chase.

 

Either way, thanks for your help.

Developer
rcmaniac25
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: displaying tiff images

If you don't mind do you think you can post up the TIFF image?

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
New Contributor
jgpark
Posts: 9
Registered: ‎07-27-2010
My Device: Not Specified

Re: displaying tiff images

I must be blind. I can't see how to post an attachment.

Developer
rcmaniac25
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: displaying tiff images

RIght side, under "Tags"

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: displaying tiff images

When posting, to the right of the area you type into, there is an Attachments panel, with a Browse Button, plus Remove/Add Attachment links.

New Contributor
jgpark
Posts: 9
Registered: ‎07-27-2010
My Device: Not Specified

Re: displaying tiff images

For some reason i don't have that option. I posted the tiff on filedropper. Here's the link: http://www.filedropper.com/a_35

Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: displaying tiff images

[ Edited ]

OK, got it, and got your problem.

 

Then I shrunk the file down, and problem went away.

 

I suspect a problem in the decoding program, they probably assumed some arbitrary maximum size and barf if it is bigger than that.

 

I would raise this on Issue Tracker, but I don't think you will have much joy with installed devices.  So I would see if you can scale down the image you send to the BlackBerry.  Alternatively, I don't think Tiff is too hard, perhaps you can decode it yourself?

Developer
rcmaniac25
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: displaying tiff images

I believe it is definitely a bug because if you debug into the getBitmap function it actually creates the Bitmap but somewhere it breaks but otherwise it does load and decode.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
New Contributor
jgpark
Posts: 9
Registered: ‎07-27-2010
My Device: Not Specified

Re: displaying tiff images

Thanks for the help! For the record, here's a working snippet of code:

 

protected void paint(Graphics graphics) {
    EncodedImage image = EncodedImage.getEncodedImageResource("A.TIF");

    int currentWidthFixed32 = Fixed32.toFP(image.getWidth());
    int currentHeightFixed32 = Fixed32.toFP(image.getHeight());

    int requiredWidthFixed32 = Fixed32.toFP(graphics.getScreenWidth());
    int requiredHeightFixed32 = Fixed32.toFP(graphics.getScreenHeight());

    int scaleXFixed32 = Fixed32.div(currentWidthFixed32, requiredWidthFixed32);
    int scaleYFixed32 = Fixed32.div(currentHeightFixed32, requiredHeightFixed32);

    EncodedImage scaledImage = image.scaleImage32(scaleXFixed32, scaleYFixed32);
    graphics.drawImage(0, 0, scaledImage.getWidth(), scaledImage.getHeight(), scaledImage, 0, 0, 0);
}

Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: displaying tiff images

Excellent, thanks for the code snippet.

 

Can you mark this as solved?