problem with scaling pictures

alwaysbusy

Expert
Licensed User
Longtime User
I'm trying to convert an app I've written in java to basic4android. I have some problems with the scaling of the background picture. It has to run on a Samsung Galaxy S (480x800x1,5 (240 dpi))

Screenshot 1 is how it should be

Screenshot 2 is the result on the Samsung Galaxy S

Screenshot 3 My settings in Basic4android.

In the java app, I put my pictures in the drawable-hdpi folder and it is scaled correcty. In b4a I only see a drawable folder.

When I create an emulator with 480x480x1 (160 dpi) the picture is shown correctly (screenshot 1). If I create an emulator with 480x800x1,5 it is wrong (screenshot 2).

Any help would be greatly appreciated.
 

alwaysbusy

Expert
Licensed User
Longtime User
Your question gave me the clue to the solution. The picture is 1440x1600. It is not drawn in b4a itself, but in java. I have a surfaceview connected to a b4a panel (very much like the camera library).

I did draw it like this:

mCanvas.drawBitmap(_bg, 0,0, null);

were I wrongly assumed it would take 480x800 pixels from the picture and put it on the canvas.

However now I do it like this:

Rect src=new Rect(0, 0, 480, 800);
Rect dst=new Rect(0, 0, 480, 800);
mCanvas.drawBitmap(_bg, src, dst, null);

And the size of the picture is correct.
 
Upvote 0

modus

Member
Licensed User
Longtime User
Galaxy S DPI

Hi alwaysbusy,
I have the same problem with my Galaxy S.
With emulator is right with 160 dpi but phone zoom 1.5x.
Have you found some solution?
Thank you
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…