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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Contributor
jerdna13
Posts: 16
Registered: ‎07-30-2012
My Carrier: Proximus
Accepted Solution

scaleImage32() method

Does anybody know why my image2 does not get scaled in the image2.scaleImage32() method?

public ZoomScreen setScreen(){

     map1.getBitmap().scaleInto(tempBmp, Bitmap.FILTER_BILINEAR); 
     Graphics g = Graphics.create(tempBmp); //works
     g.drawBitmap(100, 100, bitmapImage2.getWidth(), bitmapImage2.getHeight(), bitmapImage2, 0, 0); //works
     image2 = PNGEncodedImage.encode(tempBmp); //works
     image3 = image2.scaleImage32(Fixed32.toFP(100), Fixed32.toFP(200)); // does not work
     ZoomScreen screen = new ZoomScreen(image3);// works

  return screen;

}

 

 

Please use plain text.
Developer
peter_strange
Posts: 17,689
Registered: ‎07-14-2008

Re: scaleImage32() method

[ Edited ]

So what does happen?

 

What size do you get and what size do you expect?

 

I am wondering if you are reading the API incorrectly.  Note that the values you supply to scaleImage32 are scaling factors, not the target pixel sizes. 

Please use plain text.
Contributor
jerdna13
Posts: 16
Registered: ‎07-30-2012
My Carrier: Proximus

Re: scaleImage32() method

I get the 100x100 size but I want 400x300 for example

Please use plain text.
Developer
peter_strange
Posts: 17,689
Registered: ‎07-14-2008

Re: scaleImage32() method

So why can't you change the scaling to get the size you want?

Please use plain text.
Contributor
jerdna13
Posts: 16
Registered: ‎07-30-2012
My Carrier: Proximus

Re: scaleImage32() method

exactly :Batman:

Please use plain text.
Developer
peter_strange
Posts: 17,689
Registered: ‎07-14-2008

Re: scaleImage32() method

So you always get 100 x 100 regardless of what scaling numbers you try?  What numbers have you tried and what are the results?

Please use plain text.
Contributor
jerdna13
Posts: 16
Registered: ‎07-30-2012
My Carrier: Proximus

Re: scaleImage32() method

I tried 1000x800 and stuff like that.. the result is always same. Although can it be possible that the image resizes but when it's made larger, that it only gets drawn on a bigger canvas in the same resolution instead of getting enlarged?

Please use plain text.
Developer
Developer
CMY
Posts: 1,115
Registered: ‎02-10-2009
My Carrier: Verizon

Re: scaleImage32() method

Your issue is as peter pointed out in his first comment. The value supplied to scale32 is a scaling factor not the size that you want scaled. In your example you are saying you want to scale the image by a factor of 100 and 200. You need the Fixed32.div(x,y) functions to get the ratio that you want to scale and supply that to the scale32 function.
Please use plain text.
Developer
peter_strange
Posts: 17,689
Registered: ‎07-14-2008

Re: scaleImage32() method

Just to add to what CMY has pointed out, you said:

"bigger canvas in the same resolution "

Remember that resolution is actually not relevant on a Blackberry.  It only has so many pixels to display.  So a large canvas means more pixels and so a bigger image, a smaller canvas means fewer pixels and so a smaller image. 

 

The only time that resolution becomes important is when considering how large the Bitmap will look on the device's screen.  On something like a 8520 and 320 x 240 image will fill the screen, on a 9860 it won't of course. 

Please use plain text.