Re: Forcing a form to perfectly fit its background image



"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




.



Relevant Pages

  • Re: Firefox Compatibility, Pub2007
    ... You should of course divide the pixels/dots by the inches to get dots per ... Put a picture, your 384 X 256 pixel one for the sake of example, on your ...
    (microsoft.public.publisher.webdesign)
  • Re: Question regarding VB6
    ... your drawings without going into the complexity of using the various region ... point in the main picture box and you would have an identically shaped ... In Windows of course you still specify the values 0 to 255 for each of the rgb components regardless of the colour depth of the system, and Windows will use the nearest colour it can, but on 16 bit colour depth systems every pixel will be one of the 65536 colours that it can actually display. ... As I mentioned earlier, on 16 bit systems the red and blue components will normally be one of 32 possible values, and the green component will be one of 64 possible values. ...
    (comp.lang.basic.visual.misc)
  • Re: Question regarding VB6
    ... your drawings without going into the complexity of using the various region ... point in the main picture box and you would have an identically shaped ... In Windows of course you still specify the values 0 to 255 for each of the rgb components regardless of the colour depth of the system, and Windows will use the nearest colour it can, but on 16 bit colour depth systems every pixel will be one of the 65536 colours that it can actually display. ... As I mentioned earlier, on 16 bit systems the red and blue components will normally be one of 32 possible values, and the green component will be one of 64 possible values. ...
    (comp.lang.basic.visual.misc)
  • Re: Will F1 be on BBC HD?
    ... much sharper picture than a lower-resolution one. ... good quality HD display fed a good quality HD signal is far ... sharper than a good quality SD display fed a good quality SD ... they think you get a 1:1 pixel mapping, ...
    (rec.autos.sport.f1)
  • Re: Different resizing behaviour on 120 dpi screen
    ... Firstly, you haven't told us whether these picture boxes have borders or not, and whether or not you want all four borders on both picture boxes to be fully displayed. ... The OS cannot actually display a window of any sort on the screen that is anything other than a whole pixel value, whereas VB will calculate and store a window's Width property using whatever value you assign to it, which may or may not be a whole pixel value. ... Dim wide As Long, high As Long, pwide As Long ...
    (microsoft.public.vb.general.discussion)