 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Daniel Guest
|
Posted: Tue Aug 30, 2005 7:16 am Post subject: Quick Create a big TBitmap |
|
|
Hi,
How to create a very big TBitmap?
Let say,
bigbmp:=TBitmap.Create;
bigBmp.PixelFormat:=pf32bit;
bigBmp.Width:=20000;
bigBmp.Height:=20000;
It take a long time in allocate memory for bigBmp.
Any idea to quickly create a big TBitmap?
Thanks.
Daniel
|
|
| Back to top |
|
 |
Nicholas Sherlock Guest
|
Posted: Tue Aug 30, 2005 7:56 am Post subject: Re: Quick Create a big TBitmap |
|
|
Daniel wrote:
| Quote: | How to create a very big TBitmap?
bigbmp:=TBitmap.Create;
bigBmp.PixelFormat:=pf32bit;
bigBmp.Width:=20000;
bigBmp.Height:=20000;
|
That is a very big bitmap indeed, and you may have problems working with
it (IIRC, some video cards struggle with bitmaps larger than the screen
size). You could use Graphics32 library for this - AFAIK, it doesn't
have a restriction like this.
But having bitmaps this large smells like code that needs a rethink and
redesign.
Try resizing it as pf1bit, I think it is lighter on resources:
bigbmp:=tbitmap.create;
bigbmp.pixelformat:=pf1bit;
bigbmp.width:=20000;
bigbmp.height:=20000;
bigbmp.pixelformat:=pf32bit;
Cheers,
Nicholas Sherlock
|
|
| Back to top |
|
 |
Jens Gruschel Guest
|
Posted: Tue Aug 30, 2005 9:00 am Post subject: Re: Quick Create a big TBitmap |
|
|
| Quote: | That is a very big bitmap indeed, and you may have problems working with
it (IIRC, some video cards struggle with bitmaps larger than the screen
size).
|
Yes, especially under Win 9x.
| Quote: | You could use Graphics32 library for this - AFAIK, it doesn't
have a restriction like this.
|
Are you sure? TBitmap32 is better than TBitmap for some purposes, but I
think it still uses CreateDIBSection to allocate the whole bitmap.
Unless you are using tiling and a smart memory manager you are always
faced with such limits.
| Quote: | bigbmp:=tbitmap.create;
bigbmp.pixelformat:=pf1bit;
bigbmp.width:=20000;
bigbmp.height:=20000;
bigbmp.pixelformat:=pf32bit;
|
Again I doubt this is a good solution. IMO the pixel format should
always be set before assigning width / height, if you want to have a
DIB. Changing the pixel format after assigning a size means the DDB /
DIB has to be converted, which consumes time and (probably) more resources.
Jens
--
Jens Gruschel
http://www.pegtop.net
|
|
| Back to top |
|
 |
Francesco Savastano Guest
|
Posted: Tue Aug 30, 2005 11:09 am Post subject: Re: Quick Create a big TBitmap |
|
|
| Quote: | How to create a very big TBitmap?
Let say,
bigbmp:=TBitmap.Create;
bigBmp.PixelFormat:=pf32bit;
bigBmp.Width:=20000;
bigBmp.Height:=20000;
|
I would never do it...and it will take probably ages even if it could be
possible on WinXP
You don't need such a giant bitmap, what exactly you want to do?. If you
need it for a very large map, then you can create many bitmap blocks of the
same size and then write your own engine to update them to screen. This
would better fit into a class. The only thing I don't have much experience
with is memory mapped files that could also be the solution. for example I
think Imageen uses memory mapped TIEBitmap as solution. But 20000x20000x
4bytesPerPixel = about 1,6 GB are you conscious of this?
|
|
| Back to top |
|
 |
Jens Gruschel Guest
|
Posted: Tue Aug 30, 2005 11:40 am Post subject: Re: Quick Create a big TBitmap |
|
|
| Quote: | I would never do it...and it will take probably ages even if it could be
possible on WinXP
|
If you are lucky and your memory isn't too fragmented.
| Quote: | But 20000x20000x
4bytesPerPixel = about 1,6 GB are you conscious of this?
|
Right, I'd try to avoid allocating more than let's say 1 GB of memory on
a 32 bit multi tasking operating system.
--
Jens Gruschel
http://www.pegtop.net
|
|
| Back to top |
|
 |
Jens Gruschel Guest
|
Posted: Tue Aug 30, 2005 11:44 am Post subject: Re: Quick Create a big TBitmap |
|
|
| Quote: | bigBmp.Width:=20000;
bigBmp.Height:=20000;
|
BTW... Photoshop 6 has a limit of 30000x30000, and I successfully
created images that large. But I'm pretty sure they are storing such
bitmaps as smaller tiles. And they are using a swap disk. I think you
need a similar approach to work with such huge bitmaps.
Jens
--
Jens Gruschel
http://www.pegtop.net
|
|
| Back to top |
|
 |
Daniel Guest
|
Posted: Tue Aug 30, 2005 3:38 pm Post subject: Re: Quick Create a big TBitmap |
|
|
| Quote: | You don't need such a giant bitmap, what exactly you want to do?.
|
I need to search continuous side points of a big color block in a big
bitmap. So I have to load whole image at once.
| Quote: | memory mapped files that could also be the solution
|
I think so. I know how to create map file but not know how to load big file
directlly into it.
Any idea?
Regards,
Daniel
"Francesco Savastano" <francosavastano (AT) TakeThisOutFromAddress (DOT) virgilio.it>
级糶秎ン穝籇:43143e26$1 (AT) newsgroups (DOT) borland.com...
| Quote: | How to create a very big TBitmap?
Let say,
bigbmp:=TBitmap.Create;
bigBmp.PixelFormat:=pf32bit;
bigBmp.Width:=20000;
bigBmp.Height:=20000;
I would never do it...and it will take probably ages even if it could be
possible on WinXP
You don't need such a giant bitmap, what exactly you want to do?. If you
need it for a very large map, then you can create many bitmap blocks of
the same size and then write your own engine to update them to screen.
This would better fit into a class. The only thing I don't have much
experience with is memory mapped files that could also be the solution.
for example I think Imageen uses memory mapped TIEBitmap as solution. But
20000x20000x 4bytesPerPixel = about 1,6 GB are you conscious of this?
|
|
|
| Back to top |
|
 |
Jens Gruschel Guest
|
Posted: Tue Aug 30, 2005 5:00 pm Post subject: Re: Quick Create a big TBitmap |
|
|
| Quote: | I need to search continuous side points of a big color block in a big
bitmap. So I have to load whole image at once.
|
What does your algorithmn look like? Can you change it to scanning the
bitmap line by line? In that case you only need to have one or two lines
in memory at the same time.
| Quote: | I think so. I know how to create map file but not know how to load big file
directlly into it.
|
I think you have to write your own bitmap reader. It's not too hard,
because the bmp format is pretty simple (unfortunatelly you have to cope
with different pixel formats, unless of course you know the pixel format
of your files). Take a look at http://www.wotsit.org for more
information. Correct me if I'm wrong, but using the WinAPI calls doesn't
help, because LoadBitmap etc. do result in the same amount of memory
needed. You can use CreateDIBSection with a memory mapped file, but I'm
not sure how this will help you. Well, at least you can draw the DIB
directly to the screen once you have managed to load the file, but if
you are writing your own reader, you don't need a DIB at all (except if
your want a DC for processing it).
Jens
--
Jens Gruschel
http://www.pegtop.net
|
|
| Back to top |
|
 |
GrandmasterB Guest
|
Posted: Tue Aug 30, 2005 6:01 pm Post subject: Re: Quick Create a big TBitmap |
|
|
"Daniel" <dan59314 (AT) ms3 (DOT) hinet.net> wrote
| Quote: | I need to search continuous side points of a big color block in a big
bitmap. So I have to load whole image at once.
|
You wont need an actual bitmap for this. Rather, load the contents of the
bitmap file into a big chunk of memory and work from that. I've done
similar things to what you're doing w/ terrain elevation data, and it works
well.
|
|
| Back to top |
|
 |
Daniel Guest
|
Posted: Wed Aug 31, 2005 2:30 am Post subject: Re: Quick Create a big TBitmap |
|
|
Hi, Jens and GrandMasterB,
| Quote: | What does your algorithmn look like? Can you change it to scanning the
bitmap line by line?
|
The algorithmn I used is not to scan it line by line, that force me must
to load all data at once. Maybe splited into tiles also work, but it will
need a lot revision.
| Quote: | I think you have to write your own bitmap reader. It's not too hard,
I have the source written in C++ . Is there any source in delphi? |
| Quote: | You wont need an actual bitmap for this. Rather, load the contents of the
bitmap file into a big chunk of memory and work from that.
|
When I create a big TBitmap in runtime, time taked in allocating memory
from page file, then the HDD Led lighting for a long time. I wonder it
might be stupid and impossible to load whole bitmap quickly at once since
HDD pagefile has limit in r/w speed. I may have to consider load it tile by
tile. Is there any source that I can load one tile of a big raster file
(not only *.bmp, may be *.jpg, *.gif, *.png........)?
Thanks for kind reply,
Daniel
"Daniel" <dan59314 (AT) ms3 (DOT) hinet.net> 级糶秎ン穝籇:43147d80 (AT) newsgroups (DOT) borland.com...
| Quote: | You don't need such a giant bitmap, what exactly you want to do?.
I need to search continuous side points of a big color block in a big
bitmap. So I have to load whole image at once.
memory mapped files that could also be the solution
I think so. I know how to create map file but not know how to load big
file directlly into it.
Any idea?
Regards,
Daniel
"Francesco Savastano"
级糶秎ン穝籇:43143e26$1 (AT) newsgroups (DOT) borland.com...
How to create a very big TBitmap?
Let say,
bigbmp:=TBitmap.Create;
bigBmp.PixelFormat:=pf32bit;
bigBmp.Width:=20000;
bigBmp.Height:=20000;
I would never do it...and it will take probably ages even if it could be
possible on WinXP
You don't need such a giant bitmap, what exactly you want to do?. If you
need it for a very large map, then you can create many bitmap blocks of
the same size and then write your own engine to update them to screen.
This would better fit into a class. The only thing I don't have much
experience with is memory mapped files that could also be the solution.
for example I think Imageen uses memory mapped TIEBitmap as solution. But
20000x20000x 4bytesPerPixel = about 1,6 GB are you conscious of this?
|
|
|
| Back to top |
|
 |
Daniel Guest
|
Posted: Wed Aug 31, 2005 2:53 am Post subject: Re: Quick Create a big TBitmap |
|
|
By the way,
How can I hide my email account from these articles?
Daniel : (
"Daniel" <dan59314 (AT) ms3 (DOT) hinet.net> 级糶秎ン穝籇:4315161c$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Hi, Jens and GrandMasterB,
What does your algorithmn look like? Can you change it to scanning the
bitmap line by line?
The algorithmn I used is not to scan it line by line, that force me
must to load all data at once. Maybe splited into tiles also work, but it
will need a lot revision.
I think you have to write your own bitmap reader. It's not too hard,
I have the source written in C++ . Is there any source in delphi?
You wont need an actual bitmap for this. Rather, load the contents of
the bitmap file into a big chunk of memory and work from that.
When I create a big TBitmap in runtime, time taked in allocating memory
from page file, then the HDD Led lighting for a long time. I wonder it
might be stupid and impossible to load whole bitmap quickly at once since
HDD pagefile has limit in r/w speed. I may have to consider load it tile
by tile. Is there any source that I can load one tile of a big raster
file (not only *.bmp, may be *.jpg, *.gif, *.png........)?
Thanks for kind reply,
Daniel
"Daniel" <dan59314 (AT) ms3 (DOT) hinet.net> 级糶秎ン穝籇:43147d80 (AT) newsgroups (DOT) borland.com...
You don't need such a giant bitmap, what exactly you want to do?.
I need to search continuous side points of a big color block in a big
bitmap. So I have to load whole image at once.
memory mapped files that could also be the solution
I think so. I know how to create map file but not know how to load big
file directlly into it.
Any idea?
Regards,
Daniel
"Francesco Savastano"
[email]francosavastano (AT) TakeThisOutFromAddress (DOT) virgilio.it[/email]> 级糶秎ン穝籇:43143e26$1 (AT) newsgroups (DOT) borland.com...
How to create a very big TBitmap?
Let say,
bigbmp:=TBitmap.Create;
bigBmp.PixelFormat:=pf32bit;
bigBmp.Width:=20000;
bigBmp.Height:=20000;
I would never do it...and it will take probably ages even if it could be
possible on WinXP
You don't need such a giant bitmap, what exactly you want to do?. If you
need it for a very large map, then you can create many bitmap blocks of
the same size and then write your own engine to update them to screen.
This would better fit into a class. The only thing I don't have much
experience with is memory mapped files that could also be the solution.
for example I think Imageen uses memory mapped TIEBitmap as solution.
But 20000x20000x 4bytesPerPixel = about 1,6 GB are you conscious of
this?
|
|
|
| Back to top |
|
 |
Francesco Savastano Guest
|
Posted: Wed Aug 31, 2005 12:03 pm Post subject: Re: Quick Create a big TBitmap |
|
|
"Daniel" <dan59314 (AT) ms3 (DOT) hinet.net> ha scritto nel messaggio
news:43151b79$1 (AT) newsgroups (DOT) borland.com...
| Quote: | By the way,
How can I hide my email account from these articles?
Daniel : (
|
Just in your outlook newsgroup preferences specify a fake email address.
|
|
| Back to top |
|
 |
Daniel Guest
|
Posted: Fri Sep 02, 2005 12:37 am Post subject: Re: Quick Create a big TBitmap |
|
|
Thanks.
| Quote: | By the way,
How can I hide my email account from these articles?
Daniel : (
Just in your outlook newsgroup preferences specify a fake email address.
|
|
|
| Back to top |
|
 |
Michael Rabatscher Guest
|
Posted: Mon Sep 19, 2005 9:50 am Post subject: Re: Quick Create a big TBitmap |
|
|
An often use approach to search in big Bitmaps (e.g. Sattelite fotos) is a
pyramide approach
(convert the big image into a smaller one this and repeat the shrinking
until a good size has been found).
But for this you have to do some preprocessing which consumes some time
(creating the picture
pyramide). But searching is the a lot faster (search the small image ->
found interesting region -> search
this region in the bigger image and so on until you find it in the large
image).
unfortunatly you have to implement some kind of smart bitmap viewer which
allows you to import just
portions of the file for processing.
kind regards
Mike
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|