Link to home
Start Free TrialLog in
Avatar of NCSO
NCSO

asked on

How to load graphics fast...

Howdy,

I am playing around with a photoalbum application and most of my pictures are 4MB or larger and loading them into a picture box takes forever.

This is a two part question:

1. How do I load a picture fast into a thumbnail size?
2. How do I keep the aspect ratio on the picture?

I can split it out into two questions if you want, the first question is the most important.

So there...

I load the picture like this:

PictureBox1.Image = Image.FromFile(pics(0))

Thanks
~j
Avatar of melmers
melmers
Flag of Germany image

At first, you can convert your image to a lower resolution and file size.
I assume that you use bmp, when you conver them to jpeg then you can load them
faster

Dim myImage as Image = Image.GetFromFile("PathToFile")
myImage.Save("PathToConvertedFile.jpg",ImageFormat.Jpeg)



Avatar of NCSO
NCSO

ASKER

No 99% is jpeg's so they're already compressed.
how many pictures you have to display.
is it a solution to preload the pictures into the memory on startup of your application or are that too many pic's?
Avatar of NCSO

ASKER

It's everything from 1 picture to maybe 100.

However, I am only showing 12 at a time.   12 thumbnails, and the one selected is shown in a larger picturebox.

I thought of resizing the picture on the fly and it works great but takes time too.

I was just wondering if there was a way to read the picture in a lower resolution or something... this might sound 'tardet...

Preloading is fine, how do I preload a directory full of pictures?

Thank you
~j
I wouldn't preload the directory because of the huge memory consumtion. load 12 pictures on app start then show them, after showing load the next 12 into a hashtable or something else for the next site. when the user click on the next site show the 12 from the hashtable and load the next 12 into the hashtable.
Avatar of NCSO

ASKER

Any chance of showing me the code loading pictures into a hashtable?

tnx
~j
Are the Files indexed by a number or are they all with different names?
Avatar of NCSO

ASKER

They are for the most part file-names, like they would be from a digital camera DCN0234.jpg, DCN0235.jpg etc.

The scanned in pictures would typically have a name like Denmark1.jpg, Denmark2.jpg etc.
ASKER CERTIFIED SOLUTION
Avatar of melmers
melmers
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NCSO

ASKER

I apologize then for this late responce...

Awesome work, this work perfectly, thanks you so much, and happy New Year!

~J
Avatar of NCSO

ASKER

One question (if you're still watching it)

When I call Next or Back it gives me an error because PicCache is empty, how do I preserve it?

tnx
~j