Results 1 to 5 of 5

Thread: Image into byte array

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    shiraz
    Posts
    163

    Question Image into byte array

    hi guys
    I wanted to see how to convert a picture variable into byte array and reverce.... can i do it with jpg files too? and can i save a picture in picturebox into a jpeg file
    thank u

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    shiraz
    Posts
    163

    Re: Image into byte array

    Originally posted by mrdj1002
    hi guys
    I wanted to see how to convert a picture variable into byte array and reverce.... can i do it with jpg files too? and can i save a picture in picturebox into a jpeg file
    thank u
    no one can solve it??

  3. #3
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628
    dangits only up a 1 hour. aren't we impatient!
    You won't get many answers on the weekend, especially during the day. A large percentage of the board posters are probably in bed asleep right now due to the time differences in their countries. I can't do it but ive seen a post on this before. check the search function for "picture box and jpeg"
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  4. #4
    Addicted Member
    Join Date
    Oct 2002
    Location
    Somewhere out in space
    Posts
    151
    Originally posted by mrdj1002
    I wanted to see how to convert a picture variable into byte array and reverce....
    You can get a bit array from a picture object using the GetBimapBits API. Instead of passing to the function a long handle to a bitmap object, pass you picture object instead. Also, you can use the GetObject (api,not vb getobject function) function to get the information of the bitmap. This will help you resize your array to receive the bitmap bits. If you modify this array, you can change the bits of you picture to the one from your array by using SetBitmapBits.

    To create a picture object from an array of bytes, you have to first create a compatible bitmap, then set it's bits using SetBitmapBits and then use the OleCreatePictureIndirect function to put this bitmap into the picture object.

    note: for information about the API calls i've talked about, go check out allapi.net
    can i do it with jpg files too? and can i save a picture in picturebox into a jpeg file
    The vb LoadPicture function support .jpg files so you could load a jpeg and retreive a bit array from the picture it was loaded in. However this is only for loading and the picture box control can only save bitmap files. If you want to save jpegs, you will need to download an activex or a dll, I think that intel(?) has a free dll that you can download from the net.

    Good luck

    - Valkan
    'You keep creatures in cages and release them to fight? That's sick!'

  5. #5
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Search for GetDIBits and you should get some very recent replies which I have posted - it shows how to get an array from a DC and put it back to that.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

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