Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C# and image

C# and image

Scheduled Pinned Locked Moved C#
graphicscsharpdatabasecom
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sachees123
    wrote on last edited by
    #1

    Frnds, I have a desktop application(c# and SQL) which tries to get image from URL. What I did string imgg = PictureBoxImageAdding(dr.GetValue(0).ToString()); pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox1.Size = new System.Drawing.Size(142, 190); pictureBox1.Image = new Bitmap(imgg); It work fine with local path ie. d:/images/pics/xyz.jpg but not with http://www.xyz.com/images/pics/xyz.jpg Whats the SOLUTION.

    B R L J 5 Replies Last reply
    0
    • S sachees123

      Frnds, I have a desktop application(c# and SQL) which tries to get image from URL. What I did string imgg = PictureBoxImageAdding(dr.GetValue(0).ToString()); pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox1.Size = new System.Drawing.Size(142, 190); pictureBox1.Image = new Bitmap(imgg); It work fine with local path ie. d:/images/pics/xyz.jpg but not with http://www.xyz.com/images/pics/xyz.jpg Whats the SOLUTION.

      B Offline
      B Offline
      Bernhard Hiller
      wrote on last edited by
      #2

      Download the picture to a local (temporary) file, e.g. using HttpWebRequest from the System.Net namespace. Then load the temp file.

      1 Reply Last reply
      0
      • S sachees123

        Frnds, I have a desktop application(c# and SQL) which tries to get image from URL. What I did string imgg = PictureBoxImageAdding(dr.GetValue(0).ToString()); pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox1.Size = new System.Drawing.Size(142, 190); pictureBox1.Image = new Bitmap(imgg); It work fine with local path ie. d:/images/pics/xyz.jpg but not with http://www.xyz.com/images/pics/xyz.jpg Whats the SOLUTION.

        R Offline
        R Offline
        Rob Philpott
        wrote on last edited by
        #3

        That's because you're creating a bitmap and that only understands files, not URIs or URLs. I think you probably want to just set the ImageLocation property to imgg, or do a Load(), but haven't tried it so can't say for sure.

        Regards, Rob Philpott.

        1 Reply Last reply
        0
        • S sachees123

          Frnds, I have a desktop application(c# and SQL) which tries to get image from URL. What I did string imgg = PictureBoxImageAdding(dr.GetValue(0).ToString()); pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox1.Size = new System.Drawing.Size(142, 190); pictureBox1.Image = new Bitmap(imgg); It work fine with local path ie. d:/images/pics/xyz.jpg but not with http://www.xyz.com/images/pics/xyz.jpg Whats the SOLUTION.

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          images have to be stored in memory or in a file. Valid file paths don't start with http:// I use MemoryStream in such situations, see downloadImage() in CP Vanity[^]. :)

          Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

          1 Reply Last reply
          0
          • S sachees123

            Frnds, I have a desktop application(c# and SQL) which tries to get image from URL. What I did string imgg = PictureBoxImageAdding(dr.GetValue(0).ToString()); pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox1.Size = new System.Drawing.Size(142, 190); pictureBox1.Image = new Bitmap(imgg); It work fine with local path ie. d:/images/pics/xyz.jpg but not with http://www.xyz.com/images/pics/xyz.jpg Whats the SOLUTION.

            J Offline
            J Offline
            JOAT MON
            wrote on last edited by
            #5

            If you don't want to use a temp file, then: 1) create a web request 2) use the web request to get a web response 3) use GetResponseStream() to get stream of image 4) create image from stream 5) assign image to picturebox1.Image

            Jack of all trades ~ Master of none.

            1 Reply Last reply
            0
            • S sachees123

              Frnds, I have a desktop application(c# and SQL) which tries to get image from URL. What I did string imgg = PictureBoxImageAdding(dr.GetValue(0).ToString()); pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox1.Size = new System.Drawing.Size(142, 190); pictureBox1.Image = new Bitmap(imgg); It work fine with local path ie. d:/images/pics/xyz.jpg but not with http://www.xyz.com/images/pics/xyz.jpg Whats the SOLUTION.

              R Offline
              R Offline
              Rob Philpott
              wrote on last edited by
              #6

              You do not need to bother yourself with things like web requests to do this as others have suggested - this is completely unnecessary. As stated above just set ImageLocation to the URL you need.

              Regards, Rob Philpott.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups