Loading up Huge Image Files (Help )

henkya

Member
Joined
Nov 18, 2003
Messages
6
Hi,

I am developing a tool that functions somewhat similar to MS Paint. I got all the functionality to be working fine.

My problems arise when I have to edit huge image files (8000 x 4000 (jpeg format) around 1 MB). When I try to load the image into my picturebox, it takes a really long time.
Even after it finish loading the picture, When ever I scroll over the picturebox, it takes forever (since its redrawing).

Is there anyway that I can make the image loading to be faster, the most important thing is, is there anyway that rightafter i finished loading the image, the picturebox dont have to redraw it self again everytime we scroll the control.

The way I design the picture box is . I put the picture box on top of a panel which have the AutoScroll Property set to be True.

And every time I load the image, I do this:
Image i = Image.FromFile("test.jpg");
PictureBox.Width = i.Width;
.... same thing for height.....

PictureBox.Image = i;


I tried opening up MS Paint and use it to open the Big Image File, and while it takes quite a while to load it but right after it finished loading the picture, you can scroll around the image with ease

Sorry if I cant provide any specific chunk of codes, but I ll be more than gladly to email it to you if youre willing tohelp me out

Urgent response is greatly appreciated

Henky
 
i think for such files you have to create your own "picturebox", 8000*4000 is about 92mb if it is 24bit
 
So is there anybody out there that can give a suggestion on how to create a custom picturebox ..

plus .. the image files that im trying to read is only about 1Mb in terms of Byte size. (its in jpeg format) and its even smaller in Gif format (around 500 kb).

So size wise its not really that big
 
oh you mean diskspace i talk about memory.. in memory everything is bmp so ... :)

uhm your custom picturebox would have to only read the current needed data and not alle data of the picture..i think, maybe with some caching for a smooth scrolling
 
okay....

I stopped using the picturebox to draw my image anymore.

What I did is I used the a panel, overrides the OnPaint event for that panel.

in the OnPaint Panel I just create a graphics object of the Panel Control and call the graphics.DrawImage() method.

So based on the scrolling position I am able to draw a portion of the image which improves the loading time and performance alot.

But now how can I make the scrolling to be smooth.
You mentioned sometin bout "Caching" ?? Any helpp...??

Again thanks for the reply.
 
Actually thats what i did... sorry for the confusion on my previous wording

protected override OnPaint (balbala... couldnt remember the details e)

e.Graphics... (this is the one that I used)...



so any suggestion on how to create a customize picturebox ?????
 
Back
Top