Results 1 to 5 of 5

Thread: picture BOX LOAD .PNG PROB

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2009
    Posts
    66

    picture BOX LOAD .PNG PROB

    i had try all picture its load easy in picture box

    but png file wont load there
    picture1.picture=loadpicture(app.path & "\picname.png")

    wont load there

    i dont know wuts prob
    if someone know help plss
    i need to load png picture


    thanks in adv

    i had some png viewr but i dont understand code

    there is simple away to loaD??

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: picture BOX LOAD .PNG PROB

    VB does not support PNG files, so you need to write your own code (or use somebody elses) that will load them and convert them to a format that VB can understand.

    If you look at the help for LoadPicture, you will see this explanation:
    Graphics formats recognized by Visual Basic include bitmap (.bmp) files, icon (.ico) files, cursor (.cur) files, run-length encoded (.rle) files, metafile (.wmf) files, enhanced metafiles (.emf), GIF (.gif) files, and JPEG (.jpg) files.

    As is often the case, you can find pre-written (and well tested) examples in our CodeBank - VB6 forum, in this case I think the best is this one:
    AlphaImage Control - PNG Compatible [VB6] (by LaVolpe)

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: picture BOX LOAD .PNG PROB

    Unfortunately, VB does not support the PNG format. You cannot load a PNG file with only VB controls.

    There are at least 2 solutions that come to mind
    1. Use GDI+ which can load a PNG and draw it to the picturebox's DC. There are examples on this site
    2. Use a 3rd party usercontrol that will do it for you. Not that I am promoting my project, but I did create a couple that you can use. Here are links to those if you'd like to play with them.
    A scaled down version that supports only PNGs and animated PNGs also
    A larger version that supports many different image formats

    Edited: SI_The_Geek beat me to the reason. And thanks for the reference to my project
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4
    Member
    Join Date
    Sep 1999
    Location
    Proctor,Vt USA
    Posts
    47

    Re: picture BOX LOAD .PNG PROB

    LaVolpe your links dont work and i was interested in seeing the scaled down version

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: picture BOX LOAD .PNG PROB

    Quote Originally Posted by dmach8 View Post
    LaVolpe your links dont work and i was interested in seeing the scaled down version
    Sorry about that, those posts/projects have been pulled for personal reasons. You may find copies of the controls out on the net (search for LaVolpe Alpha Image), but other than that I am not giving that code away any longer.

    P.S. Those links were for a pretty advanced usercontrol, you don't need something that advanced if all you want to do is draw pngs to a form or picturebox. GDI+ will do that and there are plenty of examples on this forum and elsewhere.
    Last edited by LaVolpe; Jul 12th, 2009 at 05:01 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width