Results 1 to 19 of 19

Thread: Getting image from a non-image link

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2006
    Posts
    615

    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?

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    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"
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    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
    Last edited by jmsrickland; Apr 17th, 2008 at 05:39 PM.

  4. #4
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Getting image from a non-image link

    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...

    any idea how i would put that image on my program without actually downloading it to my harddrive?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2006
    Posts
    615

    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.

  6. #6
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    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.
    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?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  7. #7
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    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

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2006
    Posts
    615

    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?

  9. #9
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    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
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  10. #10
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    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.
    Last edited by jmsrickland; Apr 17th, 2008 at 05:56 PM.

  11. #11
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    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

  12. #12
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    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.

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2006
    Posts
    615

    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.

  14. #14
    Lively Member
    Join Date
    Dec 2007
    Posts
    77

    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.
    Attached Files Attached Files
    Last edited by TheOldNewbie; Apr 17th, 2008 at 07:44 PM.

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2006
    Posts
    615

    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

  16. #16

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2006
    Posts
    615

    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?

  17. #17
    Lively Member
    Join Date
    Dec 2007
    Posts
    77

    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 .

  18. #18
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    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.

  19. #19
    Lively Member
    Join Date
    Dec 2007
    Posts
    77

    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.
    Last edited by TheOldNewbie; Apr 17th, 2008 at 08:11 PM.

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