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. Load an image from a file

Load an image from a file

Scheduled Pinned Locked Moved C#
performancegraphicsquestioncode-review
7 Posts 3 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
    SeeBees
    wrote on last edited by
    #1

    I'm trying to load an image from a file and then draw it. I found out the speed is quite unacceptable. This is the case especially when I want to render several images simultaneously using Image.FromFile() and Graphics.DrawImage(). I wonder if there's any other way to improve the performance while rendering images?

    D A 2 Replies Last reply
    0
    • S SeeBees

      I'm trying to load an image from a file and then draw it. I found out the speed is quite unacceptable. This is the case especially when I want to render several images simultaneously using Image.FromFile() and Graphics.DrawImage(). I wonder if there's any other way to improve the performance while rendering images?

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      That depends on how you're drawing the images, what the images are, how big they are, ... You haven't provided any useful details so it's pretty much impossible to tell you anything useful. The quality of the answer you get is dictated by the quality of the question you ask.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      S 1 Reply Last reply
      0
      • S SeeBees

        I'm trying to load an image from a file and then draw it. I found out the speed is quite unacceptable. This is the case especially when I want to render several images simultaneously using Image.FromFile() and Graphics.DrawImage(). I wonder if there's any other way to improve the performance while rendering images?

        A Offline
        A Offline
        Anthony Mushrow
        wrote on last edited by
        #3

        Well of course its going to be slow, you've got to load up all these images of your hard disk and put them in an image object, and the draw them all. You could try loading up the images you need before they actually need to be drawn, that could speed things up. And im assuming (hoping) that you aren't loading up the images every time they need to be drawn. And i think there is some function in one o' thems dll's to do a bitblit. Which may be faster. But that would require more code on your part.

        My current favourite word is: PIE! Good ol' pie, it's been a while.

        S 1 Reply Last reply
        0
        • D Dave Kreskowiak

          That depends on how you're drawing the images, what the images are, how big they are, ... You haven't provided any useful details so it's pretty much impossible to tell you anything useful. The quality of the answer you get is dictated by the quality of the question you ask.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007

          S Offline
          S Offline
          SeeBees
          wrote on last edited by
          #4

          Thank you. What I wanna do is load all the pictures from a folder and display them all as thumbnails on a panel. For example, I have a folder containing 50 pictures of size 3000 * 2000. I used the Image.FromFile() to load all the pictures. And whenever a single picture was loaded, I used Graphics.DrawImage() to render it on the panel in no delay. That's where the problem comes. The pictures came out at a incredibly low speed. Compared to Adobe Bridge, ACDSee or other softwares of that kind, I think although my algorithm may be inpropriate, there should be a better way to load and display images than using the .NET GDI+.

          D 1 Reply Last reply
          0
          • A Anthony Mushrow

            Well of course its going to be slow, you've got to load up all these images of your hard disk and put them in an image object, and the draw them all. You could try loading up the images you need before they actually need to be drawn, that could speed things up. And im assuming (hoping) that you aren't loading up the images every time they need to be drawn. And i think there is some function in one o' thems dll's to do a bitblit. Which may be faster. But that would require more code on your part.

            My current favourite word is: PIE! Good ol' pie, it's been a while.

            S Offline
            S Offline
            SeeBees
            wrote on last edited by
            #5

            Thank you. You approach is surely better. However, I've found that using the GDI+ provided by .NET, whatever I do, even loading and displaying a single large picture is time consuming. And I don't know the o'thems as you called it. Could you please briefly explain it to me?

            A 1 Reply Last reply
            0
            • S SeeBees

              Thank you. You approach is surely better. However, I've found that using the GDI+ provided by .NET, whatever I do, even loading and displaying a single large picture is time consuming. And I don't know the o'thems as you called it. Could you please briefly explain it to me?

              A Offline
              A Offline
              Anthony Mushrow
              wrote on last edited by
              #6

              Sadly, i don't know what the function is called, what dll it is in, or how to use it. Sorry:((

              My current favourite word is: PIE! Good ol' pie, it's been a while.

              1 Reply Last reply
              0
              • S SeeBees

                Thank you. What I wanna do is load all the pictures from a folder and display them all as thumbnails on a panel. For example, I have a folder containing 50 pictures of size 3000 * 2000. I used the Image.FromFile() to load all the pictures. And whenever a single picture was loaded, I used Graphics.DrawImage() to render it on the panel in no delay. That's where the problem comes. The pictures came out at a incredibly low speed. Compared to Adobe Bridge, ACDSee or other softwares of that kind, I think although my algorithm may be inpropriate, there should be a better way to load and display images than using the .NET GDI+.

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                SeeBees wrote:

                For example, I have a folder containing 50 pictures of size 3000 * 2000.

                No wonder... In order to generate the thumbnail, GDI is loads the entire file into memory then generates the thumbnail. GDI+ is a generalized library, preferring compatibility over speed. If you want to improve performance, you'll need to find a third party graphics library that gives you the perfromance features you need. Figure out what your requirements are, then go shopping.

                A guide to posting questions on CodeProject[^]
                Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                     2006, 2007

                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