Board index » cppbuilder » Form layout in different resolutions and scaling images

Form layout in different resolutions and scaling images

Hi,

Does anyone know how to preserve a form's layout when switching between
different resolutions?  Also, is it possible to scale an image down to
fit inside of a control while still maintaining the images aspect ratio?

I have a form with four images, a TImage object in each corner of the
form.  The form comes up maximized with no borders.  It looks fine when
I run it in the same resolution as when I designed it (1600X1200) but
when I lower the resolution, the form gets truncated.  I tried
dynamically setting the form's Width and Height property to the current
screen resolution, experimented with PixelsPerInch, Scaled, AutoSize,
Anchors etc. but nothing seems to work.  For some reason the layout
always comes up larger than the physical display.  I would like an image
to appear in each corner of the form without scroll bars.

In addition, I could not figure out a way to get the images to scale
well inside of the image control.

Can anyone help?  Thanks in advance.  Dom.

 

Re:Form layout in different resolutions and scaling images


On Sun, 12 Mar 2000 21:57:35 -0500, Dominic Odescalchi

Quote
<dom...@altavista.net> wrote:
>In addition, I could not figure out a way to get the images to scale
>well inside of the image control.

You'll probably find you need to create various images in different
sizes and color depths and load dynamically when your program
finds out what resolution and color depth the user is running.
There's no quick fix 'cept maybe to shell out for a component
that helps with the controls and fonts and such.  Messing around
with images for a web page I've found that true color seems to look
okay down to 16 bit color depth, but to avoid looking like {*word*99} on
a 256 color monitor(if anyone is still using them) you should load
a 256 color image.  If you have a limited target for your app then
you might do some research to see what they run.  I guess most
of the PCs now with Windows preloaded come set at 800x600
high color 16 bit video by default.  You might use that as a base
(if your customers are likely to leave that setting.)

Mike
--

"A man's only as old as the woman he feels."
         -- Groucho Marx

Re:Form layout in different resolutions and scaling images


Hi Mike,

Thanks for answering.  Unfortunately, I don't know what images I will be
displaying until run-time.  My customers build a database of images and I
just read the database and display.  I calculate how much screen real
estate I can devote
to each image based on the run-time resolution and I need to be able to
scale each image from the database to fit inside of the maximum area.

I already wrote functions to scale an image while maintaining the correct
aspect ratio but you can't set the width and height property of a
TPicture object.  I thought I might be able to put the Images into a
TPanel object, set the Panel object's width and height to the scaled
dimensions and turn the Images stretch property to true, but that doesn't
seem to work either.

Any suggestions would be greatly appreciated.

Thanks, Dom.

Quote
Michael Kelly wrote:
> On Sun, 12 Mar 2000 21:57:35 -0500, Dominic Odescalchi
> <dom...@altavista.net> wrote:

> >In addition, I could not figure out a way to get the images to scale
> >well inside of the image control.

> You'll probably find you need to create various images in different
> sizes and color depths and load dynamically when your program
> finds out what resolution and color depth the user is running.
> There's no quick fix 'cept maybe to shell out for a component
> that helps with the controls and fonts and such.  Messing around
> with images for a web page I've found that true color seems to look
> okay down to 16 bit color depth, but to avoid looking like {*word*99} on
> a 256 color monitor(if anyone is still using them) you should load
> a 256 color image.  If you have a limited target for your app then
> you might do some research to see what they run.  I guess most
> of the PCs now with Windows preloaded come set at 800x600
> high color 16 bit video by default.  You might use that as a base
> (if your customers are likely to leave that setting.)

> Mike
> --

> "A man's only as old as the woman he feels."
>          -- Groucho Marx

Other Threads