resizing an image to different screen resoulution

Monkey Forums/Monkey Programming/resizing an image to different screen resoulution

dave.h(Posted 2011) [#1]
is it possible to load an image and make it fit onto the screen. ie like a background image.Ive tried this but when you change to a different resolution part of the image is missising. in c++ you could use stretchrect


therevills(Posted 2011) [#2]
Have you tried the SetScale command?


dave.h(Posted 2011) [#3]
ive tried

Scale (SCREEN_WIDTH/WIDTH), (SCREEN_HEIGHT/HEIGHT)


where screen_width is the devicewidth() and width is the picture width
and screen_height is the deviceheight() and height is the picture height

which works ok.gotta admit though im kinda fumbling about in the dark here as im not sure how to get things working on different android phones that use different resolutions


therevills(Posted 2011) [#4]
Ahhh you want some virtual resolution stuff, not just scaling images...

Okay you can either check out James Boyd's Auto-fit example or do something like this:



This will display a red rectangle which will cover the entire display on all devices.

I'm doing this with my game and I have tested it on a few phones with different resolutions... it works fine.


dave.h(Posted 2011) [#5]
yes i tested it and it works great. i had something similiar at the end but havent used pushmatrix and popmatrix as im not sure what they mean.Actually ive no no idea what they mean but i do understand the rest.Im new to this and apreciate all the help given.do you need to use them in conjunction with the scale command?.


therevills(Posted 2011) [#6]
You dont need to use the matrix commands with scale... I normally do, so when I add text to the screen its displays at the device resolution so its nice and clear.

		PushMatrix 
			Scale SCREEN_WIDTH/WIDTH, SCREEN_HEIGHT/HEIGHT
			SetColor 255, 0, 0
			DrawRect 0, 0, WIDTH, HEIGHT
		PopMatrix
		DrawText "Test", 0, 0



dave.h(Posted 2011) [#7]
ok thanks


Citty(Posted 2014) [#8]
this did not help