Board index » delphi » Desperately need help with large images....

Desperately need help with large images....

Hi

I'm busy working on a project where I need to load in large .BMP files
into an Image box in Delphi (some of the images are over 4000x4000
pixels). I also need to run the program in hi-color, as well as 256 colour
modes. At the moment, the Image control supplied with Delphi 2.0 seems to
be unable to cope with images that large when the system memory is 16Mb or
lower. If you have any ideas on how I can still load the large images
without Windows/Delphi falling over from lack of resources, please let me
know your thoughts.

In addition, when running in 256 colour mode, when I minimize my app
and flip to another application, then Windows changes the palette.
However, when I come back into my application, my displayed image has the
wrong colours, and I manually have to force a re-draw of the image box.
I've tried putting the redraw as Application.OnActivate, as well as the
form's 'onResize' and 'onShow' events, but none of these seem to work.
Once again, any feedback would be very welcome.

Since I am in South Africa and things are a bit slow here, if you could
e-mail me responses directly I would greatly appreciate it. My e-mail is
true...@eastcoast.co.za

Thank you for your consideration.

Yours sincerely,

Richard Tanner-Tremaine.

 

Re:Desperately need help with large images....


Quote
truetec wrote:

> Hi

> I'm busy working on a project where I need to load in large .BMP files
> into an Image box in Delphi (some of the images are over 4000x4000
> pixels). I also need to run the program in hi-color, as well as 256 colour
> modes. At the moment, the Image control supplied with Delphi 2.0 seems to
> be unable to cope with images that large when the system memory is 16Mb or
> lower.

        There may be a 16MB restriction somewhere. If (on a 256-color system)
I say

procedure TForm1.Button1Click(Sender: TObject);
var bmp:TBitmap;
begin
bmp:=TBitmap.Create;
bmp.Width:=4000;
bmp.Height:=4000;
bmp.canvas.rectangle(0,0,100,100);
canvas.draw(0,0,bmp);
bmp.free;
end;

the bitmap appears, it just takes a while. But if I replace the 4000's
with 5000's I get an out of resources error.

(Note that 4000x4000x24-bit would be almost 48MB.)

Come to think of it another possibility is that I'm running out
of disc space. I don't know the D2 story, but back in D1 loading
a bitmap actually required an amount of memory 2 or 3 times the
size of the bitmap - I only have 40MB or so free.

There must be an alternative to loading a huge image like this
in one chunk. Surely you could open just the part you want to
look at right now?

--
David Ullrich
Sig file accidentally deleted - sorry.

Re:Desperately need help with large images....


In article <4pjufn$...@hermes.is.co.za>, truetec
<true...@eastcoast.co.za> writes

Quote
>Hi

>I'm busy working on a project where I need to load in large .BMP files
>into an Image box in Delphi (some of the images are over 4000x4000
>pixels). I also need to run the program in hi-color, as well as 256 colour
>modes. At the moment, the Image control supplied with Delphi 2.0 seems to
>be unable to cope with images that large when the system memory is 16Mb or
>lower. If you have any ideas on how I can still load the large images
>without Windows/Delphi falling over from lack of resources, please let me
>know your thoughts.

If the images themselves are 8-bit or hi-color images then you may need
to process the image in chunks and draw it onto the canvas yourself. If
the images contain few colours, then you are best to load the images
directly into a DIB and draw that DIB onto your canvas - that way you
don't need to have a BMP consistent with the screen device context to
display it.

I have successuflly displayed 10000x15000 pixel b&w images on HiColor
displays using DIBs.

Quote
>Yours sincerely,

>Richard Tanner-Tremaine.

--
Raymond Wilson

Re:Desperately need help with large images....


X-Newsreader: Galahad 1.3

Quote
David Ullrich wrote:

>Come to think of it another possibility is that I'm running out
>of disc space. I don't know the D2 story, but back in D1 loading
>a bitmap actually required an amount of memory 2 or 3 times the
>size of the bitmap - I only have 40MB or so free.

>There must be an alternative to loading a huge image like this
>in one chunk. Surely you could open just the part you want to
>look at right now?

>--
>David Ullrich
>Sig file accidentally deleted - sorry.

You need something that can load it in bands. Imageman library can do this
I believe.

http://data-tech.com/

--
Arnold Bailey - abai...@bix.com - abai...@webwrights.com
WebWrights - Web Services, Web Pages and Web Site Management
http://www.webwrights.com/

Other Threads