Re: Forcing a form to perfectly fit its background image
- From: "Mike Williams" <Mike@xxxxxxxxxxxxxxxxx>
- Date: Sat, 4 Mar 2006 09:55:33 -0000
"K" <nospam@xxxxxxxxxx> wrote in message news:kT3Of.6334$S25.4990@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I'm using VB6 and at run-time I assign an image file as the background
of my main form using form1.picture=<filename>. What's the best way
to force the size of the form to exactly match the size of the picture,
assuming the picture is always smaller than the screen.
There's a short answer and a long one. Here is the first part of the long one ;-)
The first thing you need to know is that a picture doesn't really have a "size", at least not in the way you seem to be looking at it. For example, if you take a picture with a camera (analogue or digital) and ask a high street photo shop to print it for you the first thing they'll ask is, "How big to you want it"? The picture itself is just a bunch of data, and a digital picture is just a block of pixels. If the resolution of the camera when you took the picture was 1600 x 1200 for example and you display that picture at its full "pixel size" on a typical monitor running at a typical 96 pixels per logical inch then the picture will have a "size" of 16.7 x 12.5 logical inches. If you were to write code to deliberately print the exact same picture "pixel for pixel" (so that one "picture pixel" occupied exactly one "printer pixel") to a typical inkjet printer set to draft mode (typically 300 dots per inch) it will print at a size of 5.3 x 4 logical inches and if the same printer is set to high quality (typically 600 dots per inch) it will print at a size of just 2.6 x 2 inches. So, as you can see, displaying or printing a picture "pixel for pixel" will produce a picture whose size depends on the size of each pixel in the output device. That is not the way things are normally done.
So, you need to "tell" the output device how big you want the picture to be (just as you need to tell the man in the high street photo shop how big you want him to print it). The output device drivers (whether it be the screen or the printer) will then compress or expand the original "picture pixels" onto the output device in such a way as to produce an output of exactly the size you require. Also, some devices (the screen, for example) can make each one of their "device pixels" any colour they wish out of a typical pallete of millions of colours, whereas other devices (typical inkjet pixels for example) have only three or perhaps five or six different coloured ink tanks to work with and so in order to get an approximation of the desired colour at any given point they need to "mix these colours together" to produce the result. Therefore, they work best when there is a large number of "printer pixels" for each "picture pixel" at your specified picture output size, so quality printers tend to have very large resolutions. As as the picture pixels themselves are concerned, for good quality photos on a typical inket printer you need at least 150 "picture pixels" for every "printed inch" on the printer. VB can actually "tell" the printer to print the picture at any size you want, but the 1600 x 1200 pixel picture we have talked about will print out best if you specify a printed output size of about 10 inches by 8 inches (or less, of course). Any more than 10 x 8 inches and it will begin to look a bit "grainy".
Anyway, I'm in a bit of a rush at the moment so I'll post the actual answer to your question later today, or perhaps someone else will post an answer for you in the meantime, but I just thought it is important for you to understand the above stuff before you actually get into sizing your pictures.
Mike
.
- References:
- Prev by Date: Re: Help for a newbie
- Next by Date: Re: Does a certain file exist?
- Previous by thread: Forcing a form to perfectly fit its background image
- Next by thread: Re: Forcing a form to perfectly fit its background image
- Index(es):
Relevant Pages
|