Board index » delphi » loading LARGE bitmaps, stitching them, then saving result in 1 file w/o tbitmap
Sean Roulo
![]() Delphi Developer |
Sat, 14 Aug 2004 08:01:32 GMT
|
Sean Roulo
![]() Delphi Developer |
Sat, 14 Aug 2004 08:01:32 GMT
loading LARGE bitmaps, stitching them, then saving result in 1 file w/o tbitmapI need to stitch together a number of 500x500 pixel bitmaps to create a single image that can exceed 10000x10000 pixels. Windows 98/95/ME has problems with bitmaps >16mb and gives resource error when you try to define the bitmaps height and width. I have a feeling there Is there a way to build this bitmap file in memory and save to disk as one huge bitmap from something like a tstream. Problem is I'm not sure how. The bitmaps come from 65k color jpeg files on disk so I assume they are 24 or 32 bit bmps - if that matters. Any ideas would be greatly appreciated. Thanks in advance, Sean |
Earl F. Glyn
![]() Delphi Developer |
Sat, 14 Aug 2004 11:03:18 GMT
Re:loading LARGE bitmaps, stitching them, then saving result in 1 file w/o tbitmapQuote"Sean Roulo" <s...@magicalmaps.com> wrote in message news:3c7ad05c$1_2@dnews... error when you try to define the bitmaps height and width. You'll have a variety of problems in Windows 9x. You have a chance in Windows 2000 or XP. -- |
Sean Roul
![]() Delphi Developer |
Sat, 14 Aug 2004 13:03:15 GMT
Re:loading LARGE bitmaps, stitching them, then saving result in 1 file w/o tbitmapEarl, Thanks for your reply and thanks for making that large bitmap demo. correct me if I'm wrong but your program is designed to test exactly how large of a bitmap your individual windows version/ video adapter/ memory etc. will let tbitmap object create. What I'm suggesting is rather than try to use the tbitmap object (where I would get trouble from win9x) instead try to build a memory mapped file by hand-calculating the bitmap header and image data bytes by merging the individual bitmap files. This would require knowing the specific file structure/layout of bitmap files, which I do not. I imagine there is some kind of header to the file that tells the height and/or width, and perhaps pixel format, etc. I just don't really have a clue how to start or where to look for that. I know there is some folks that could write the routine in about 5 minutes or less and I was hoping they might be reading this message about now. If so I've got some cash to pay for help writing this. Thanks, Sean |
Sue D. No
![]() Delphi Developer |
Sat, 14 Aug 2004 14:17:18 GMT
Re:loading LARGE bitmaps, stitching them, then saving result in 1 file w/o tbitmapWell, I stitch together many 1200 x 900 pixel bitmaps, normally 4 x 4 pages max at 4800 x 3600 pixels to as many as 10 x 10 (12,000 x 9,000 pixels). I have written 20 x 30 page chunks out to a 36 inch plotter with good results. Although PhotoShop and such can deal with megapixel bitmaps, I think that anything over about 4,000 on a side is the kiss of death for Win 95 machines and am planning my app accordingly. 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; It can be slow, even on a gigahertz machine but you can allocate bitmaps hundreds of megs in size. You can stitch large bitmaps together relatively painlessly by writing to a large format plotter canvas, such as an HP 36 inch roll plotter. By writing to a file or saving spooler output you get a file of the plot. I think the stream idea might be feasible. The images need to be read into a jpeg component to create an available bitmap. You create a bitmap header and stream it out first. Next, it will be necessary to know the byte order that the image is loaded in a LoadFromStream. Let's assume that it fills all columns in a row then loads the next row. In this case, it would be necessary to load all the tiles ACROSS the output bitmap, then stream all the rows in the bitmap height. Then, load the next row of images and repeat the You need to make sure that the bytes are all properly aligned in the bitmap. See the documentation of scanline to see how various resolutions may result in pad bytes to round out a video display line. QuoteSean Roulo wrote: |
Rene Tschaggela
![]() Delphi Developer |
Sat, 14 Aug 2004 17:35:51 GMT
Re:loading LARGE bitmaps, stitching them, then saving result in 1 file w/o tbitmapThe fileformats are available at http://www.wotsit.org And yes, you could have an array[0..9999,0..9999]of integer, a mere 400 MBytes and move it back and forth from the memory to the graphics card. A machine of today has at least 512 MB. Oops, on yesterdays it'll swap a bit. Rene QuoteSean Roulo wrote: |
DP
![]() Delphi Developer |
Sat, 14 Aug 2004 22:12:22 GMT
Re:loading LARGE bitmaps, stitching them, then saving result in 1 file w/o tbitmapIf you use CreateDibSection and FileMapping you should be able to write really huge bitmaps. Using alone CreateDIBSection without FileMapping I was able to create 6400 by 4800 pix bitmap with no problems on Win98 machine. All I can say is Best of luck DP Quote"Sean Roulo" <s...@magicalmaps.com> wrote in message Quote
problems with bitmaps >16mb and gives resource error when you try to define the bitmaps height and width. I have a feeling there Is there a way to build this bitmap file in memory and save to disk as one huge bitmap from something like a tstream. Problem is I'm not sure how. The bitmaps come from 65k color jpeg files on disk so I assume they are 24 or 32 bit bmps - if that matters. Quote
|
Andrew Rybenko
![]() Delphi Developer |
Sun, 15 Aug 2004 01:19:15 GMT
Re:loading LARGE bitmaps, stitching them, then saving result in 1 file w/o tbitmapQuote>This would require knowing the specific file structure/layout of bitmap files, which I do not. I imagine there is some hope this simple routine will help you "to start" :) procedure SaveToFileBMP(const aBmp: TBitmap; aFileName: String); with bmfh do begin with bmih do begin n := aBmp.Width; BmpToArray(aBmp,Pointer(pSrc)); AssignFile(f,aFileName); @L1: pop edi if something is unclear, ask |
Joe C. Hech
![]() Delphi Developer |
Sun, 15 Aug 2004 02:10:45 GMT
Re:loading LARGE bitmaps, stitching them, then saving result in 1 file w/o tbitmapI have a library I privatly sell that works with very large bitmaps, jpegs, andd TWAIN sources... Email for more info Joe Quote"Sean Roulo" <s...@magicalmaps.com> wrote in message news:3c7ad05c$1_2@dnews... feeling there Is there a way to build this bitmap file in memory and save to disk as one huge bitmap from something like a tstream. Problem is I'm not sure how. The bitmaps come from 65k color jpeg files on disk so I assume they are 24 or 32 bit bmps - if that matters. Quote
|
Sean Roul
![]() Delphi Developer |
Sun, 15 Aug 2004 02:31:53 GMT
Re:loading LARGE bitmaps, stitching them, then saving result in 1 file w/o tbitmapRene, Thanks for the post and the link (condensed version is attached at bottom of message). I downloaded the file and I think I have a pretty good grasp on what needs to be done. It seems I just need to calculate the size of the bitmap in height and width, then calculate the byte size of the header and add that to the number of image pixels times 3(bytes) to get the file size. Is there an end of file byte and should that be counted in file size? one thing I am a little bit confused about is when it mentions could anyone out there please enlighten me on what I am supposed to do here. I assume the file needs to be a size divideable by 32 if not pad the file with #0 (or just 0)?. Great thanks in advance! Sean QuoteRene Tschaggelar <tschagge...@dplanet.ch> wrote: a color table, and an array of bytes that defines the bitmap bits. The file has the following form: BITMAPFILEHEADER bmfh; The bitmap-file header contains information about the type, size, and layout typedef struct tagBITMAPFILEHEADER { /* bmfh */ Quote} BITMAPFILEHEADER; layout of a device-independent bitmap (DIB) file. Member Description bfType Specifies the type of file. This member must be BM. Comments A BITMAPINFO or BITMAPCOREINFO structure immediately follows the =========================================================================== typedef struct tagBITMAPINFOHEADER { /* bmih */ Member Description biSize Specifies the number of bytes required by the biWidth Specifies the width of the bitmap, in pixels. biPlanesSpecifies the number of planes for the target device. This biBitCount Specifies the number of bits per pixel. This value must be 1, biCompression Specifies the type of compression for a compressed bitmap. It Value Meaning BI_RGB Specifies that the bitmap is not compressed. BI_RLE8 Specifies a run-length encoded format for bitmaps with 8 bits BI_RLE4 Specifies a run-length encoded format for bitmaps with 4 bits biSizeImage Specifies the size, in bytes, of the image. It is valid to biXPel{*word*237}eter Specifies the horizontal resolution, in pixels per meter, of biYPel{*word*237}eter Specifies the vertical resolution, in pixels per meter, of biClrUsed Specifies the number of color indexes in the color table If the biClrUsed member is nonzero, it specifies the actual number of colors biClrImportant Specifies the number of color indexes that are considered Comments The BITMAPINFO structure combines the BITMAPINFOHEADER structure and a color An application should use the information stored in the biSize member to pColor = ((LPSTR) pBitmapInfo + (WORD) (pBitmapInfo->bmiHeader.biSize)) See Also The bitmap-information header, defined as a BITMAPINFOHEADER structure, The color table, defined as an array of RGBQUAD structures, contains as many The BITMAPINFO structure can be used to represent a combined The biBitCount member of the BITMAPINFOHEADER structure determines the number Value Meaning 1 Bitmap is monochrome and the color table contains two entries. Each 4 Bitmap has a maximum of 16 colors. Each pixel in the bitmap is 8 Bitmap has a maximum of 256 colors. Each read more » |
Sean Roul
![]() Delphi Developer |
Sun, 15 Aug 2004 03:28:18 GMT
Re:loading LARGE bitmaps, stitching them, then saving result in 1 file w/o tbitmapAndrew, WOW. thanks for the post. I do have a couple of questions. :) bfType := Ord('M') shl 8 or Ord('B'); then comes the asm :( part. I don't know asm so I'm kind of in the dark here. Think I understand the following Quote
also if you are feeling really generous -if you could give me a step by step comment on the asm code that would be way cool and probably more than I deserve! :) Thanks, Sean Quote"Andrew Rybenkov" <aryben...@hotmail.com> wrote: |
Andrew Rybenko
![]() Delphi Developer |
Sun, 15 Aug 2004 06:04:09 GMT
Re:loading LARGE bitmaps, stitching them, then saving result in 1 file w/o tbitmapQuote> bfType := Ord('M') shl 8 or Ord('B'); Quote> > GetMem(p,n*3); just because of specifics of GetMem this bug did not affected execution of the routine, and I saw it only now. Quote> this makes sure the row width is a factor of 4 if not, it bumps up m until it is a factor of 4 (rather 4 is a factor). Quote> end of each line? it is BlockWrite(f,p^,m); where padding is done Quote> it seems that this would need to be done from the text about 32 bit boundaries in my last post to rene. if so I would Quote> each horizontal tile's row - if that makes sense. then pointer p is pointed to a reserved block of memory to hold an Quote> added to make the row div 4. Quote> also if you are feeling really generous -if you could give me a step by step comment on the asm code for i := aBmp.Height-1 downto 0 do begin // saving from bottom scanline to top mov ecx,n // ECX <-- count of colors in a scanline @L1: pop edi // restoring "spoiled" registers BlockWrite(f,p^,m); // while we sent n colors, to file we write m colors, thus doing padding hope this helps. |
Nils
![]() Delphi Developer |
Sun, 15 Aug 2004 17:25:16 GMT
Re:loading LARGE bitmaps, stitching them, then saving result in 1 file w/o tbitmapIt just means that your scanlines must always be a multiple of 4 bytes. True color bitmaps seem to work no other way anyhow so it should not be a Kind regards, QuoteSean Roulo <s...@magicalmaps.com> wrote in message Quote
on what needs to be done. It seems I just need to calculate the size of the bitmap in height and width, then calculate the byte size of the header and add that to the number of image pixels times 3(bytes) to get the file size. Is there an end of file byte and should that be counted in file size? Quote
file with #0 (or just 0)?. Quote
large of a bitmap your individual windows version/ video adapter/ memory etc. will let tbitmap object create. What I'm suggesting is rather than try to use the tbitmap object (where I would get trouble from win9x) instead try to build a memory mapped file by hand-calculating the bitmap header and image data bytes by merging the individual bitmap files. Quote> >This would require knowing the specific file structure/layout of bitmap that tells the height and/or width, and perhaps pixel format, etc. I just don't really have a clue how to start or where to look for that. I know there is some folks that could write the routine in about 5 minutes or less and I was hoping they might be reading this message about now. If so I've got some cash to pay for help writing thi - Hide quoted text - - Show quoted text - Quote> >s. == - Hide quoted text - - Show quoted text - Quote> BITMAPINFOHEADER (3.0) read more » |