Getting image from a non-image link
Hey guys, I was wondering how would i be able to get this image onto my VB project?
http://ichart.finance.yahoo.com/b?s=DIS
Notice that when you open that, it brings it up as an image. But I have code to put images directly from the internet onto my Image1. The thing is, it wont work for that since it doesn't have a .png or .jpg or .gif or any of those extentions.
any idea how i would put that image on my program without actually downloading it to my harddrive?
Re: Getting image from a non-image link
I don't have vb6 in front of me so could you please confirm whether the image control supports the .png extns. I know it does support .jpg and .gif
What does
Image1.Picture = "http://ichart.finance.yahoo.com/b?s=DIS" give you assuming that it supports png?
as the link which you have given is a .png file and the name of the file is "b.png"
Re: Getting image from a non-image link
I don't think the Image or the Picturebox supports .PNG
EDIT
I was able to get it onto my hard drive and I can display it by double clicking on it but I cant load it into my Picturebox control. It is downloaded as a .png. Now I know .png files are not supported
Re: Getting image from a non-image link
Quote:
NO, but here it is if you want it.
He doesn't want to download it. He wants to directly show it in his application... :)
Quote:
any idea how i would put that image on my program without actually downloading it to my harddrive?
Re: Getting image from a non-image link
Quote:
Originally Posted by koolsid
I don't have vb6 in front of me so could you please confirm whether the image control supports the .png extns. I know it does support .jpg and .gif
What does
Image1.Picture = "http://ichart.finance.yahoo.com/b?s=DIS" give you assuming that it supports png?
as the link which you have given is a .png file and the name of the file is "b.png"
Im aware its a png file. And an image control can take any image file extensions if i understood you right on that part.
but anyways
Im wondering, just incase someone doesn't know the code to get the image to the image control without downloading, if its possible someone could also supply me with the code to download that image to the harddrive and then put it from the harddrive to the image control.
Re: Getting image from a non-image link
Quote:
And an image control can take any image file extensions if i understood you right on that part.
What I meant was that since i cannot check it can you confirm by checking the control in design mode by clicking the picture property of image1 to check if png is supported in the box that opens?
Re: Getting image from a non-image link
And an image control can take any image file extensions if i understood you right on that part.
No, Not .png files. They are not supported
Re: Getting image from a non-image link
oh, alright. well, you are able to save it as a jpg on the computer and it still works anyways under that extention. Any idea how i would download the image to my harddrive then?
Re: Getting image from a non-image link
Quote:
Originally Posted by GRPsuper9
oh, alright. well, you are able to save it as a jpg on the computer and it still works anyways under that extention. Any idea how i would download the image to my harddrive then?
This will get you started...
http://www.dreamincode.net/code/snippet48.htm
Re: Getting image from a non-image link
Just right click on the image and save it to your hard drive as a .bmp file then rename it to a .png file
Even so, .png files are not supported.
Re: Getting image from a non-image link
How bad do you want this picture?
If you get LViewPro (it's free) it will convert any picture to any other format.
If you can't find it let me know and I will post a zip file of it
Re: Getting image from a non-image link
Lavolpe has created a VB6 control for displaying PNG images.
http://www.pscode.com/vb/scripts/Sho...68262&lngWId=1
You would download the image from your VB project the same as you would any other image and save it as a .png then load it into Lavolpe's control.
Re: Getting image from a non-image link
Quote:
Originally Posted by jmsrickland
Just right click on the image and save it to your hard drive as a .bmp file then rename it to a .png file
Even so, .png files are not supported.
Im asking to download it with my program, not manually download it or use another program to download it and convert it with. Also, this does NOT need to be converted. All that needs to be done to it to be put on a Image Control is to change the extension from .png to .jpg.
And ill check out all the links you guys gave me.
1 Attachment(s)
Re: Getting image from a non-image link
This is some thing I D/L'd from some webpage but can not remember where, maybe PSC. Use the API below to download the png and then use the ZIP module to put it in a Picturebox or Image Control.
Code:
'put this in the Declarations
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, _
ByVal szFileName As String, ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Private Declare Function GetSysColor Lib "User32" (ByVal nIndex As Long) As Long
Code:
'use this to download image to harddrive
Dim strURL as String 'url of image
Dim strLocalFile as String ' file path to download to HDD
Dim lPic as Long,lCol as Long
lPic = URLDownloadToFile(0, strURL, strLocalFile, 0, 0)
' put an error trap here
'then load the image to the PictureBox with this
lCol = Picture1.BackColor
If lCol < 0 Then lCol = GetSysColor(lCol - &H80000000)
Token = InitGDIPlus
Picture1.Picture = LoadPictureGDIPlus(strLocalFile, , , lCol)
FreeGDIPlus Token
Let us know if it doesn't work.
Re: Getting image from a non-image link
I just used this code
Code:
Dim byteData() As Byte
Dim xFile As Integer
byteData() = Inet1.OpenURL("http://ichart.finance.yahoo.com/b?s=DIS", icByteArray)
xFile = FreeFile
Open "C:\TempImage.jpg" For Binary Access Write As #xFile
Put #xFile, , byteData()
Close #xFile
If anyone finds out how to download it and put it directly on the picturebox or image control, please let me know. For now, ill just download it to the harddrive since its my only choice
Re: Getting image from a non-image link
Quote:
Originally Posted by TheOldNewbie
This is some thing I D/L'd from some webpage but can not remember where, maybe PSC. Use the API below to download the png and then use the ZIP module to put it in a Picturebox or Image Control.
zip module? where do i get a zip module from? you got one i can have?
Re: Getting image from a non-image link
Add a Module to your App, UnZip the file and C/P to the Module.
I also edited my post so make the changes to your code if you have copied it .
Re: Getting image from a non-image link
[B]All that needs to be done to it to be put on a Image Control is to change the extension from .png to .jpg.
It won't work. The internal code defines it as a .png format so the external extension has no effect on it.
Re: Getting image from a non-image link
Quote:
Originally Posted by GRPsuper9
zip module? where do i get a zip module from? you got one i can have?
Hey Bud, did you get it to work?
P.S. Sorry Bud, I didn't read your post well enough. The "Zip Module" that I referred to was the Zip File that I attached to my post.