Active Forums => QB64 Discussion => Topic started by: bartok on October 09, 2021, 05:42:55 am
Title: LOCATE problem
Post by: bartok on October 09, 2021, 05:42:55 am
Hi, I was testing my program in an other PC, with a smaller screen then mine, and I found that it doesn't work.
I was astonisched by that, because I have figured this problem and in order to avoid it, any image descends from _DESKTOPWIDTH and _DESKTOPHEIGHT and it is smaller. so, the images must fit the screen, and I didn't thought to LOCATE.
the image attached is a result of 2 images. the graphic is pasted with _PUTIMAGE over the bigger image, containing data. data are written on the right of the bigger image with locate. but the problem is that if in my screen, LOCATE ,192 put the data as in the picture attached, in smaller screens, LOCATE ,192 is "outside" of the screen.
I ask you if there is a way in order to always have the data written as in the picture, in all the screens.
Thank's you.
Title: Re: LOCATE problem
Post by: SMcNeill on October 09, 2021, 06:45:29 am
Instead of an absolute coordinate, LOCATE via a scaleable one.
For example, the screen you displayed has a width of 232 characters, or so, I'm guessing. Let's pretend it's 232 characters anyway, for this explanation, so you have 40 characters reserved on the right of the screen to print your text in.
Instead of a hardcoded LOCATE ,192 -- which might be offscreen on some smaller screens -- simply LOCATE , maxWidth - 40 instead.
On screens that are 232 characters wide, you print starting at position192. On screens that are only 200 characters wide, you print starting at position 160.
Of course, if you want ALL screens to look the same regardless of resolution, use TWO screens in your program.
WorkScreen is the one you draw and render everything on. Make it the size you need to hold your data. DisplayScreen is set to the users desktop height and width.
Simply make the DisplayScreen the visible one, and _PUTIMAGE the WorkScreen on it, to scale to the proper resolution.
Or add a $RESIZE command to the top of your code.
Title: Re: LOCATE problem
Post by: OldMoses on October 09, 2021, 06:48:08 am
_PUTIMAGE should have a way to keep things in frame. If you _putimage both graphic AND data to an intermediate image sized to accept both, then _putimage that intermediate image to the screen, such that it shrinks things to fit, would that keep things still readable and without distortion? AH, I see Steve beat me to it, same idea essentially.
Here's a little sub I've been using lately that shrinks and justifies images to fit in defined spaces without altering their aspect ratio.