Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

size of Picture Control

461 views
Skip to first unread message

Eric

unread,
Jan 29, 2007, 1:27:48 PM1/29/07
to
I need to display a small image in a dialog. So I used the Picture Control
and sized it to the space I have in the dialog (VS2005 shows me 50x35). Then
I created an image of 50x35 pixel and saved it as bitmap, imported it into a
resource (where it reads 50x35 pixel), set the Picture Control to Type
Bitmap and selected in the Image field the bitmap resource. Now I have a
bitmap of 33x22 on the dialog, in other words much smaller than I wanted and
than I have drawn the bitmap. The switch Real Size Image has no effect. How
can I keep the image in the size I want?

I know that dialogs are in dialog units, and that the picture resizes with
the dialog would be ok. I don't want to write any code to resize the image
(if necessary I'll redraw the image in an image program). What can I do?

Eric


AliR (VC++ MVP)

unread,
Jan 29, 2007, 1:41:14 PM1/29/07
to
You shouldn't have to. When you run the program it should display
correctly. (Normally when I close the dialog and reopen it in the resource
editor, it displays the correct pictrue and size). If I remember correctly
the resource editor doesn't even let you resize a picture control, it
automatically takes the size of the bitmap.

AliR.

"Eric" <bauer...@kull.ch.cuthere.nospam.me.com> wrote in message
news:ePsZDN9...@TK2MSFTNGP02.phx.gbl...

Eric

unread,
Jan 29, 2007, 1:43:30 PM1/29/07
to
(after several hours, but just after posting my question)
Comparing the bitmap of the dialog (shown as 33x22) and the bitmap (50x35
pixel) in a graphic editor has shown that they were identical in size. So it
was actually really only a dialog unit problem.
This means that (on my PC) 1 dialog unit is 1.5 pixel. I've redrawn the
bitmap to 75x53 pixel and now it shows up as the desired size of 50x33 in
Visual Studio. When there's another ratio of dialog units to pixel then it
should resize accordingly.

Eric


Joseph M. Newcomer

unread,
Jan 31, 2007, 3:08:13 PM1/31/07
to
It is never, ever, safe to assume that the bitmap rendering and the DBU rendering have any
fixed correlation with each other. Redrawing an image to fit one particular size of
control is a doomed approach. It means that this program will work ONLY on your machine,
and ONLY with your current video card, display, display driver, and default font
selection. It is safe to assume that it will probably fail to operate correctly on nearly
any other machine in the known universe.

There are two approaches to this problem. The simplest one is to simply resize the bitmap
object (e.g., the CStatic) dynamically to fit the bitmap. The slightly more complex
approach is to resize the bitmap to the size of the control, using StretchBlt (which often
produces ugly effects if there is a serious size mismatch). The third solution is to have
a suite of images in various sizes; choose the image nearest in size and then apply one of
the two previous solutions.

While you can consider doing conversions using Dialog Box Units, but this is typically
unnecessary.
joe
On Mon, 29 Jan 2007 19:43:30 +0100, "Eric" <bauer...@kull.ch.cuthere.nospam.me.com>
wrote:

Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

Joseph M. Newcomer

unread,
Jan 31, 2007, 3:16:40 PM1/31/07
to
See my answer to your "problem solved" posting (try to use the same subject line to make
tracking the responses easier).

You have confused dialog box units (DBUs) with pixels. As I mention in my answer,
redrawing the image to fit the picture control area precisely is doomed, and is a
completely unacceptable solution if you ever plan to run your program on any other machine
in the known universe, or at any time upgrade your machine, change its display,
resolution, or default font.

I find fewer unpleasant artifacts by making large images smaller than small images larger
when I use StretchBlt. But at no time would I consider redrawing the image to "fit
precisely" as a viable solution. It won't work except in one, and only one, precise case.
All attempts to redraw the image will require that you create one image for each possible
combination of display screen size, display resolution, video card vendor, and version of
display driver, for all possible settings of default fonts. This means a lot of pictures.
That's probably about 8 screen resolutions, 6 screen sizes, 3 font sizes, and that means
124 pictures, and I've probably missed a few. And that doesn't even take into account the
idiosyncrasies of display cards and drivers.
joe
On Mon, 29 Jan 2007 19:27:48 +0100, "Eric" <bauer...@kull.ch.cuthere.nospam.me.com>
wrote:

Eric

unread,
Feb 1, 2007, 10:16:43 AM2/1/07
to
Hello Joseph
Thanks for your contribution.
I thought when I redraw the image to this size, so that it fits on my
screen, it later automatically causes a resize when the ratio of DU (dialog
units) to pixels changes. But you make me feel that this won't work as I
have thought.
It looks like I have to use a much bigger bitmap and use StretchBlt(?) to
resize it.
Anyway, there's currently no more budget to implement this and probably this
will look a little ugly on other machines. But the tool must be finished
tomorrow and I currently have much bigger problems than the customer's icon
on the dialog. Probably I'll fix this later (or never).
Thank you for your help.
Eric


0 new messages