Load an image from a file
-
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()
andGraphics.DrawImage()
. I wonder if there's any other way to improve the performance while rendering images? -
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()
andGraphics.DrawImage()
. I wonder if there's any other way to improve the performance while rendering images?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 -
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()
andGraphics.DrawImage()
. I wonder if there's any other way to improve the performance while rendering images?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.
-
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, 2007Thank 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 usedGraphics.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+. -
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.
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?
-
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?
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.
-
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 usedGraphics.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+.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