Board index » delphi » Vary large bitmaps > 16Mb Windows XP PixelFormat = pf24bit

Vary large bitmaps > 16Mb Windows XP PixelFormat = pf24bit


2003-09-04 04:02:00 AM
delphi41
Bottom Lines:
1. Windows XP won't let me create a 32MB bitmap (out of resources)
unless I set PixelFormat = pf24bit (not my observation, see credit
below). Why (just curious), and can I trust it?
2. At some point creating very large bitmaps (I suspect>16 MB),
Windows must write them to disk rather than RAM. How can I find that
point programmatically (if not 16Mb limit regardless RAM size, which I
suspect) for my user?
For example, this code:
procedure TMainForm.FormCreate(Sender: TObject);
begin
with TBitmap.Create do
try
try
begin
//.... won't allow as little as 32MB without following line
{PixelFormat := pf24bit;}
Height:= Trunc(Sqrt(32 * 1024 * 1024) + 0.5);
Width:= Height;
ShowMessage('32Mb bitmap created OK')
end
except on EOutOfResources do
ShowMessage('Try setting PixelFormat = pf24Bit, stupid')
end
finally
begin
ShowMessage('Freeing memory');
Free
end
end
end;
By setting PixelFormat = pf24bit, I can load a 256Mb bitmap onto my
hard disk in about a minute on my 2-something GHz PB-not machine -
only I can not actually do anything much with it anyway without waiting
out universes of time.
Of course it is no hardship to set PixelFormat = pf24bit as I need that
anyway to exploit the ScanLine property of TBitmap (8-18 in Borland's
D6 'Developer's Handbook' - although it is hard to understand what the
example is supposed to do).
I would have never guessed pf24bit without searching this newsgroup -
these newsgroups so useful. Credit:
From: "Sue D. Nom" <.....>
Subject: Re: loading LARGE bitmaps, stitching them, then saving result
in 1 filew/o tbitmap
Date: Tue, 26 Feb 2002 00:17:18 -0600
Groups: borland.public.delphi.graphics
wrote
<For producing large bitmaps, an NT class OS is required. It took
under 20 seconds to create a 10K x 10K bitmap in PaintShop Pro, 7
seconds to create a bitmap on a 500 MHz machine with 256 meg memory,
using this code:
Bmp := TBitmap.Create;
Bmp.PixelFormat := pf24bit;
Bmp.Width := 10000;
Bmp.Height := 10000
...>
I need these very large bitmaps because I am about to interest myself
in antialiasing using the sub-pixelling treatment described in New
Foley Now In C (oh dear) p 134. Sprouts and furious transforms look
very interesting for sure, but not the stuff you (me anyway) can toss
off in a few evenings and I would rather put them to simmer gently pretty
well for ever on the back burner if Ican get away with it.
BTW, if anyone knowledgeable waded in this far, anyone know how Corel
Photopaint (my Chines takeaway is version 7.0) does antialiasing? My
experiments strongly suggest to me it is using nothing more
sophisticated than Uncles F's unweighted area sampling technique
mentioned above.
William Boyd
 
 

Re:Vary large bitmaps > 16Mb Windows XP PixelFormat = pf24bit

Hi
Windows GDI has a limitation regarding bitmap size. It can not create a
bitmap above certain size. The maximum bitmap size varies from system to
system and I don't think that there's a way to calculate it. I think that
you could use a plain non-GDI memory bitmap which is nothing else but a
buffer of bytes. But be shure that each scanline inside buffer has the size
which is a multiplyer of number 4 in order to to draw it to screen
afterwards. This metod will alow you to create as large bitmap as you have
memory but the drawback is that you can not use GDI functions on it.
regards,
Tomaz
"William Reid Boyd" <XXXX@XXXXX.COM>writes
Quote
Bottom Lines:

1. Windows XP won't let me create a 32MB bitmap (out of resources)
unless I set PixelFormat = pf24bit (not my observation, see credit
below). Why (just curious), and can I trust it?

2. At some point creating very large bitmaps (I suspect>16 MB),
Windows must write them to disk rather than RAM. How can I find that
point programmatically (if not 16Mb limit regardless RAM size, which I
suspect) for my user?

For example, this code:

procedure TMainForm.FormCreate(Sender: TObject);
begin
with TBitmap.Create do
try
try
begin
//.... won't allow as little as 32MB without following line
{PixelFormat := pf24bit;}
Height:= Trunc(Sqrt(32 * 1024 * 1024) + 0.5);
Width:= Height;
ShowMessage('32Mb bitmap created OK')
end
except on EOutOfResources do
ShowMessage('Try setting PixelFormat = pf24Bit, stupid')
end
finally
begin
ShowMessage('Freeing memory');
Free
end
end
end;

By setting PixelFormat = pf24bit, I can load a 256Mb bitmap onto my
hard disk in about a minute on my 2-something GHz PB-not machine -
only I can not actually do anything much with it anyway without waiting
out universes of time.

Of course it is no hardship to set PixelFormat = pf24bit as I need that
anyway to exploit the ScanLine property of TBitmap (8-18 in Borland's
D6 'Developer's Handbook' - although it is hard to understand what the
example is supposed to do).

I would have never guessed pf24bit without searching this newsgroup -
these newsgroups so useful. Credit:

From: "Sue D. Nom" <.....>
Subject: Re: loading LARGE bitmaps, stitching them, then saving result
in 1 filew/o tbitmap
Date: Tue, 26 Feb 2002 00:17:18 -0600
Groups: borland.public.delphi.graphics

wrote

<For producing large bitmaps, an NT class OS is required. It took
under 20 seconds to create a 10K x 10K bitmap in PaintShop Pro, 7
seconds to create a bitmap on a 500 MHz machine with 256 meg memory,
using this code:

Bmp := TBitmap.Create;
Bmp.PixelFormat := pf24bit;
Bmp.Width := 10000;
Bmp.Height := 10000

...>

I need these very large bitmaps because I am about to interest myself
in antialiasing using the sub-pixelling treatment described in New
Foley Now In C (oh dear) p 134. Sprouts and furious transforms look
very interesting for sure, but not the stuff you (me anyway) can toss
off in a few evenings and I would rather put them to simmer gently pretty
well for ever on the back burner if Ican get away with it.

BTW, if anyone knowledgeable waded in this far, anyone know how Corel
Photopaint (my Chines takeaway is version 7.0) does antialiasing? My
experiments strongly suggest to me it is using nothing more
sophisticated than Uncles F's unweighted area sampling technique
mentioned above.

William Boyd
 

Re:Vary large bitmaps > 16Mb Windows XP PixelFormat = pf24bit

"William Reid Boyd" <XXXX@XXXXX.COM>writes
Quote
Bottom Lines:

1. Windows XP won't let me create a 32MB bitmap (out of resources)
unless I set PixelFormat = pf24bit (not my observation, see credit
below). Why (just curious), and can I trust it?

I think it depends on your video driver. GDI will attempt to allocate the
bitmap in video memory first, asking the video driver to deal with it. If
the video driver says it doesn't have enough video RAM available, GDI will
revert to allocating the bitmap bits from main memory. It may be that your
video driver or GDI itself handles requests for the standard 24bit format
better than the peculiar pixel formats like 32bit or 15/16 bit.
-Danny
 

Re:Vary large bitmaps > 16Mb Windows XP PixelFormat = pf24bit

if you use a DDB type bitmap (default) it is limited usually to the
desktop screen
size*2.0 on most systems.
if you use a DIB then its only limited by memory.
simply set the pixel format to what you want and the Tbitmap component
will
create the DIB section for you in your host memory..
William Reid Boyd writes:
Quote
Bottom Lines:

1. Windows XP won't let me create a 32MB bitmap (out of resources)
unless I set PixelFormat = pf24bit (not my observation, see credit
below). Why (just curious), and can I trust it?

2. At some point creating very large bitmaps (I suspect>16 MB),
Windows must write them to disk rather than RAM. How can I find that
point programmatically (if not 16Mb limit regardless RAM size, which I
suspect) for my user?

For example, this code:

procedure TMainForm.FormCreate(Sender: TObject);
begin
with TBitmap.Create do
try
try
begin
//.... won't allow as little as 32MB without following line
{PixelFormat := pf24bit;}
Height:= Trunc(Sqrt(32 * 1024 * 1024) + 0.5);
Width:= Height;
ShowMessage('32Mb bitmap created OK')
end
except on EOutOfResources do
ShowMessage('Try setting PixelFormat = pf24Bit, stupid')
end
finally
begin
ShowMessage('Freeing memory');
Free
end
end
end;

By setting PixelFormat = pf24bit, I can load a 256Mb bitmap onto my
hard disk in about a minute on my 2-something GHz PB-not machine -
only I can not actually do anything much with it anyway without waiting
out universes of time.

Of course it is no hardship to set PixelFormat = pf24bit as I need that
anyway to exploit the ScanLine property of TBitmap (8-18 in Borland's
D6 'Developer's Handbook' - although it is hard to understand what the
example is supposed to do).

I would have never guessed pf24bit without searching this newsgroup -
these newsgroups so useful. Credit:

From: "Sue D. Nom" <.....>
Subject: Re: loading LARGE bitmaps, stitching them, then saving result
in 1 filew/o tbitmap
Date: Tue, 26 Feb 2002 00:17:18 -0600
Groups: borland.public.delphi.graphics

wrote

<For producing large bitmaps, an NT class OS is required. It took
under 20 seconds to create a 10K x 10K bitmap in PaintShop Pro, 7
seconds to create a bitmap on a 500 MHz machine with 256 meg memory,
using this code:

Bmp := TBitmap.Create;
Bmp.PixelFormat := pf24bit;
Bmp.Width := 10000;
Bmp.Height := 10000

...>

I need these very large bitmaps because I am about to interest myself
in antialiasing using the sub-pixelling treatment described in New
Foley Now In C (oh dear) p 134. Sprouts and furious transforms look
very interesting for sure, but not the stuff you (me anyway) can toss
off in a few evenings and I would rather put them to simmer gently pretty
well for ever on the back burner if Ican get away with it.

BTW, if anyone knowledgeable waded in this far, anyone know how Corel
Photopaint (my Chines takeaway is version 7.0) does antialiasing? My
experiments strongly suggest to me it is using nothing more
sophisticated than Uncles F's unweighted area sampling technique
mentioned above.

William Boyd
 

Re:Vary large bitmaps > 16Mb Windows XP PixelFormat = pf24bit

On Wed, 3 Sep 2003 22:33:27 +0200, "Tomaz Koritnik"
<XXXX@XXXXX.COM>writes:
Quote
I think that you could use a plain non-GDI memory bitmap which is nothing else but a buffer of bytes. But be sure ...
On Wed, 3 Sep 2003 13:54:14 -0700, "Danny Thorpe" <XXXX@XXXXX.COM>
writes:
Quote
It may be that your video driver or GDI itself handles requests for the standard 24bit format better than the peculiar pixel formats like 32bit or 15/16 bit.
Thanks for the idea, Tomaz, and the info Danny - appreciated.
In fact it ocurred to me this morning that I can almost certainly do
this unweighted area sampling without subpixelling. I think it is just
an interesting exercise in affine geometry - pretty sure that is right.
But in any case I will do it first by subpixelling, but confine myself
to 256 by 256 bits (subpixelling on 16MB), because I get off on things
like that.
Thanks again,
William Boyd