Loading images async
-
My application requries loading all the pictures from a specified folder, and then reading the exif meta data off them. Pictures will be displayed by PictureBoxes, and that the images are loaded using the PictureBox.Image property. I cannot make it work by using the PictureBox.LoadAsync() function because the LoadAsync() method does not read the exif meta data. And here are my questions: 1) Is there any way to generate the images without first loading the whole image into memeory? As of this moment, my thumbnails are generated by first setting the PictureBox.Image property, and then use the PictureBox.getthumbnailimage and then setting the PictureBox.image to the thumbnail, which first loads the whole image into memeory, and then generating one, and then finally assigning it back to the picture box 2) Is there any way to load the picture Async without using the LoadAsync() function. Or is there any way to load the picture using the LoadAsync() function while keeping all the exif meta data available? thank you very much
-
My application requries loading all the pictures from a specified folder, and then reading the exif meta data off them. Pictures will be displayed by PictureBoxes, and that the images are loaded using the PictureBox.Image property. I cannot make it work by using the PictureBox.LoadAsync() function because the LoadAsync() method does not read the exif meta data. And here are my questions: 1) Is there any way to generate the images without first loading the whole image into memeory? As of this moment, my thumbnails are generated by first setting the PictureBox.Image property, and then use the PictureBox.getthumbnailimage and then setting the PictureBox.image to the thumbnail, which first loads the whole image into memeory, and then generating one, and then finally assigning it back to the picture box 2) Is there any way to load the picture Async without using the LoadAsync() function. Or is there any way to load the picture using the LoadAsync() function while keeping all the exif meta data available? thank you very much
Hi, some comments: 1. you don't need a PictureBox to generate a thumbnail. You can use the Image class, with Image.FromFile() or Image.FromStream(). Then do new Bitmap(image, newWid,newHei) and dispose of the original image. 2. If you need to keep the EXIF data, you may want to copy it into some kind of list (otherwise you can't dispose of the image, hence are loading your memory a lot). 3. You can do the above in one or a few threads, hence async with respect of your main thread. I would not use more than 2*N threads here, if N is the number of processors (See Environment.ProcessorCount). :)
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
-
Hi, some comments: 1. you don't need a PictureBox to generate a thumbnail. You can use the Image class, with Image.FromFile() or Image.FromStream(). Then do new Bitmap(image, newWid,newHei) and dispose of the original image. 2. If you need to keep the EXIF data, you may want to copy it into some kind of list (otherwise you can't dispose of the image, hence are loading your memory a lot). 3. You can do the above in one or a few threads, hence async with respect of your main thread. I would not use more than 2*N threads here, if N is the number of processors (See Environment.ProcessorCount). :)
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
Is there any way to generate the thumbnail without loading the whole image into memeory first? I realize that by using the Image will load into memory right away. How do i do the above async? There is no loadasync method in the Image class Also, is there a way to tell if the picture has finish loaded into memory? perhaps by extending the picturebox or something?
-
Is there any way to generate the thumbnail without loading the whole image into memeory first? I realize that by using the Image will load into memory right away. How do i do the above async? There is no loadasync method in the Image class Also, is there a way to tell if the picture has finish loaded into memory? perhaps by extending the picturebox or something?
2hdass wrote:
Is there any way to generate the thumbnail without loading the whole image into memeory first?
no, unless you want to implement your own file parser/thumbnailer yourself for all relevant file formats.
2hdass wrote:
How do i do the above async?
with additional threads, as I told you before.
2hdass wrote:
is there a way to tell if the picture has finish loaded into memory?
for Image.FromFile(): when it returns.
2hdass wrote:
perhaps by extending the picturebox or something?
forget about PictureBox if all you need is a thumbnail. Reread my previous reply! :)
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google