From: Nando on
Hi all! I have a little program (written in VB6) that saves the image in
a picturebox to a BMP file. The problem is that BMP files are several
megabytes in size and do not support DPI (dots-per-inch) information for
printing.

I have turned to the PNG format which provides lossless compression
(files are only few kilobytes) and includes DPI information.

But how do I save the image in a picturebox to a PNG file?

Thanks in advance!
From: Mike Williams on
"Nando" <hightech(a)att.net.no.to.sp.am> wrote in message
news:uflaC5aMLHA.2100(a)TK2MSFTNGP06.phx.gbl...

> Hi all! I have a little program (written in VB6) that saves the
> image in a picturebox to a BMP file. The problem is that BMP
> files are several megabytes in size and do not support DPI
> (dots-per-inch) information for printing. I have turned to the
> PNG format which provides lossless compression (files are
> only few kilobytes) and includes DPI information.

The png format will give you those kind of lossless compressions (50:1 or
even more) on simple images, such as line drawings with filled sections and
graphs and other images with a limited number of colours and many small or
large areas of a solid colour, but the png lossless compression of a tpyical
photo will be much less, perhaps in the order of 2:1 or something of that
nature. So, if your images are of the kind I first mentioned then png is
definitely one way to go if you want high compression, but if they are
typical photos (and if compression is your main concern) then the lossy but
still quite good compression of a jpg might be more suitable (although the
fact that png can give you lossless compression on photos might be exactly
what you want if compression is not your main concern). As far as DPI
information in an image file is concerned, that's a moot point that I won't
go into here because I sometimes get into lots of trouble from various
people for writing too much waffle :-)

> But how do I save the image in a picturebox to a PNG file?

I reckon GDI+ is probably your best bet. Have a look at:

http://www.vbaccelerator.com/home/vb/code/vbmedia/using_gdi_plus/Reading_and_Writing_JPG__PNG__TIF_and_GIF_Files/article.asp

Mike




From: MikeD on


"Nando" <hightech(a)att.net.no.to.sp.am> wrote in message
news:uflaC5aMLHA.2100(a)TK2MSFTNGP06.phx.gbl...
> Hi all! I have a little program (written in VB6) that saves the image in a
> picturebox to a BMP file. The problem is that BMP files are several
> megabytes in size and do not support DPI (dots-per-inch) information for
> printing.
>
> I have turned to the PNG format which provides lossless compression (files
> are only few kilobytes) and includes DPI information.
>
> But how do I save the image in a picturebox to a PNG file?


VB6 does not natively support the PNG format. Look for an OCX or DLL that
does (sorry, I personally don't know of any or I'd suggest one). Or, I
suppose you could search the Internet for the PNG format's file spec and
write the file yourself. Finding an OCX/DLL would probably be a lot easier,
and I'd be willing to bet there are free ones out there that shouldn't be
too hard to find.

--
Mike



From: Shotgun Thom on
Nando...

There are plenty of free resources out there for saving an image in
the PNG format.

One is the Free Image open source DLL. It even has VB6 examples.
It's open source and available at:

http://freeimage.sourceforge.net/sourcecode.html

Even Microsoft provides that ability with the Windows Image
Acquisition Library (WIA) found here:

http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=a332a77a-01b8-4de6-91c2-b7ea32537e29

Mike Williams also gave you a good resource at vbAcclerator.

And, btw, Mike.... one man's waffle is another man's treasure. I
usually learn something with your "waffles". Don't stop now!

Tom

From: Horst Heinrich Dittgens on
> And, btw, Mike.... one man's waffle is another man's treasure. I
> usually learn something with your "waffles". Don't stop now!

what I would like to underwrite, too!