Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to display png graphics in picture/image box. 2

Status
Not open for further replies.

SidYuca

Technical User
Nov 13, 2008
79
MX
will someone direct me to way to display png graphics in picture/image box?
 
The problem, of course, is that VB's LoadPicture (and the underlying API that it wraps) predate the png file format, and so cannot load them.

So we need to find a newer library that does understand png and can also returned such an image as an OLE picture (which is what VB understands).

Fortunately, Microsoft have provided such a library called the Windows Image Aquisition library (or WIA) which is pretty easy to use (and compared tio the normal LoadPicture adds support for both TIF and PNG file formats, but does not directly support ICO or CUR file formats). Here's a basic replacement for the normal VB LoadPicture function that should achieve what you are asking for:
Code:
[blue]Public Function NewLoadPicture(strPath As String) As StdPicture
    With CreateObject("WIA.ImageFile")
        .LoadFile (strPath)
        Set NewLoadPicture = .FileData.Picture
    End With
End Function[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top