# Small problem with VB6

This topic is 3584 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi guys... Im just getting back to my VB6 roots and was messing around with the internet transfer control. got it to download an image from a supplied url and saved it to a file. the file (no matter the format) can be imported into the picture property of a picture box. however, if i open the file in windows picture and fax view (paint works too) through windows explorer and save it again without make any changes, then try and import it, it works. heres my code:
Dim pic() As Byte
pic() = Inet1.OpenURL("http://www.website.com/image.png", icByteArray)
Open "C:\Program Files\Common Files\1.gif" For Binary Access Write As #1
Put #1, , pic()
Close #1
Set PictureBox1.Picture = LoadPicture("C:\Program Files\Common Files\1.gif")
i know that the image i am downloading is in png format and i am saving it in gif format. this works. the file saves normally. I think that VB6 still thinks the image is a png...? Any help appreciated! Spawned218.

##### Share on other sites
If you download it in PNG format, it'll still be in PNG format unless you explictly convert it (changing the file extension isn't enough).

##### Share on other sites
how does one specifically convert it then?

##### Share on other sites
Quote:
 Original post by Spawned218how does one specifically convert it then?

You can open them in an editor and save them in another format. There are also programs written for the sole purpose of conversion, these tools usually have batch conversion and maybe renaming etc.

links to a few tools you could use if you don't already have something:
http://www.getpaint.net/
http://www.irfanview.com/
http://www.snapfiles.com/get/bimp.gif.html

##### Share on other sites
what i meant was, how do i convert them through VB6 code. doing it externally is easy... open and resave in paint/windows picture and fax viewer. image works perfectly after that. but the program is dynamic. the image will be different depending for each user...

can anybody aid me?

##### Share on other sites
You will need to convert the image from png to gif, so you'll need to know the layout of the gif format and png format.
To convert between the two you will need to change the bytes in the array you have downloaded (to change the byte array layout from the png into the gif format.)

##### Share on other sites
Look for either a COM+ component to do it, or a Win32 dll that you can easily use from within VB6.