Results 1 to 4 of 4

Thread: Loading PicBox from memory (binary data)

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    3

    Lightbulb Loading PicBox from memory (binary data)

    Hi all.

    I need to load a PictureBox with image data that I have in memory during the running of my code. I could save the image to the HD and the use the LoadPicture to load it, but that involves reading/writing to the HD, which I am trying to avoid.

    Does anybody know of anyway to do this? I know the hDC of the PictureBox so I am hoping there's some whizzy GDI API call I can use to simply transfer my memory contents into the PictureBox.

    Any advice or suggestions much appreciated

    inf.

  2. #2

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    3

    Re: Loading PicBox from memory (binary data)

    Hi RhinoBull and thanks for your reply. Let's see if I can explain my situation some more...

    My code successfully allows the user to pick an MP3 file from their HD and then examines the ID3 tags inside the MP3, and picks out Artist, Song, Album etc. If the ID3 tags are version 2, my code then successfully looks for an embedded Album Cover Picture inside the MP3. If it finds one, I would like to display that image inside a PictureBox control on my form.

    The image data is held in my code in a Byte array and I also have it as a String. I have successfully written that data to disk (e.g. to C:\test.jpg) and then loaded the PictureBox e.g. pic1.Picture = LoadPicture("C:\test.jpg") and the image appears fine. However, I would like to achieve the same result (i.e. the image appears in the PictureBox), without have to save the data to a disk file and then load it back from disk into the PictureBox.

    Therefore, to summarise, I would like to take the Byte Array or String of Binary data, and load it directly to the PictureBox to show the image. I can't see any built-in method of the PictureBox to do this, so I'm guessing some sort of API call is needed, using the hDC of the PictureBox.

    Any help or direction much appreciated

    Edit : Forgot to say that the image format will mostly be JPEG but may also be PNG. I'd be happy to just get JPEG working first and worry about PNG later.
    Last edited by infaddict; Jul 13th, 2006 at 03:39 AM.

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Loading PicBox from memory (binary data)

    Quote Originally Posted by infaddict
    ... to summarise, I would like to take the Byte Array or String of Binary data, and load it directly to the PictureBox to show the image...
    Perhaps sample from the following article will work for you:

    Can we view a picture from its memory data?

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