0

I'm working on a game, it's almost complete (just tweaking & testing), I have Samsung galaxy S1, so graphics works just fine on Galaxy S1 and S2, however.. tested on Samsung galaxy S3; had to create image resizer function to resize all the files when loaded, now it works just fine on that. But, I don't have all Android devices to test the graphics on different screen size. I've created different screen size devices on emulator(AVDM), tried on them, but bad result (ramsize, heap size had to be unreal to test properly).

That's a background info. Ok, let me get to the point; I haven't tested the game on bigger screen devices but tested on Samsung Galaxy S3, graphics were smaller on S3 since it loaded images from mdpi folder. So, what I'm doing with my graphics is, loading pre-resized images and I get the device's screen size and trying to resize them manually with float values to make sure the graphics is not too small nor big for current screen while the "AnyDensity=false" on manifest.xml. It's easier to do that when you actually test on the specific devices to get expected result. I've disabled the auto-resize function to fasle to avoid "OutOfMemoryError" when android resizes graphics automatically. It works, but it's hard to assume the float value when you can't predict the screen size.

I want to hear your experience on this, what do you guys suggest on such situation? How do you resize your graphics for different screen size devices to fit perfectly on the screen knowing current screen width and height values?

An example: forest_1.png width/height: 600 x 400 px on Samsung Galaxy S1 (533 x 320) screen would render perfectly, but how to predict the exact values to resize forest_1.png image for Android Note II without having the device to test? (Note II screen size is 1280 x 720 )

Any comments / suggestions would be appreciated, thanks!

GameBug
  • 136
  • 2
  • 10

1 Answers1

0

In my opinion you will need to resize the image programmatically. Examples you can find in answers here: Image crop and resize in Android

And this is how you get the dimensions of your device: Get screen dimensions in pixels

Community
  • 1
  • 1
Marcin Bak
  • 1,410
  • 14
  • 25
  • Hi Marcin Bak, Thanks for the reply. My problem is not how to get screen size, or how to resize bitmap, rather how to detect in what scale images should be resized for different screen sizes. An example: forest_1.png: 600 x 400 px on Samsung Galaxy S1 (Device screen size: 533 x 320) screen would render perfectly, but how to predict the *exact values* to resize forest_1.png? (Note II screen size is 1280 x 720 ), what the width and height for resizing the above image should be for different screen size? there should be some sort of calculation, how to calculate it? thanks! – GameBug Jan 16 '13 at 20:14
  • 1
    I'm not sure if I understand it well. But just blind guess, simple proportion of screen sizes (reference and target )wouldn't do the trick? eg. width_ratio = 720/400 = 1.8 and height_ration = 1280/600 = approx. 2.13? The problem here is that those two screens have different screen width/height ratio so either you would need to get 1.8 scale and have slightly narrower image comparing to screen width or take 2.13 and crop the image/allow it to have more height. Hope it helps somehow – Marcin Bak Jan 17 '13 at 23:04
  • Exactcly... I've tried that, but for some screens getting width ratio isn't good enough since it leaves some space on the top and bottom of the screen. I think that crop idea sounds good, but it is sad that it won't look exact same after cutting them in center. But thanks for confirming Marcin Bak, thought there would be some other solution. Cheers! – GameBug Jan 18 '13 at 00:47