The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Mr Earl on November 28, 2005, 12:39:47 PM

Title: Bitmap array
Post by: Mr Earl on November 28, 2005, 12:39:47 PM
How do you concatenate several bitmaps into a single bitmap?
Title: Re: Bitmap array
Post by: u on November 28, 2005, 02:56:28 PM
I don't know enough about GDI+, but the normal method is:

Load the .bmp files into separate memory buffers, and then copy segments (lines) of them onto one big buffer. Finally, save it into a .bmp file. But you should learn the .bmp file format (find it at www.wotsit.org)
Title: Re: Bitmap array
Post by: Grincheux on November 28, 2005, 07:03:51 PM
Create a bitmap in a memory DC. It size is the size of the two bitmaps
Select the new bitmap into the memory DC
Select the first orginal bitmap into a DC
copy with BitBlt or StretchBlt form the hDC to the memory DC
Select the second original bitmap into a DC
copy with BitBlt or StretchBlt form the hDC to the memory DC

Example :

The first bitmap is 256 * 384.
The second has the same size.

The resulting bitmap will be 512 * 384

INVOKE GetDC,hWnd
mov hDC,eax
INVOKE CreateCompatibleDC,hDC
mov hDCMem,eax
invoke CreateCompatibleBitmap,hDC,512,384
mov hBmpResult,eax
invoke SelectObject,hDCMem,eax
mov hBmpMem,eax
invoke SelectObject,hDC,hBmp_1
mov hBmpOld,eax
invoke BitBlt,hDCMem,0,0,256,384,hDC,0,0,SRCCOPY
invoke SelectObject,hDC,hBmp_2
invoke BitBlt,hDCMem,256,0,256,384,hDC,0,0,SRCCOPY
invoke SelectObject,hDC,hBmpOld
invoke SelectObject,hDCMem,hBmpMem

; Now initialize a BITMAPINFO Structure
; Only the 6 first parameter are required
; Call GetDIBits to get all the bitmap bits

After that you can write the bitmap to the file
The BITMAPFILEINFOHEADER has to be initialized before.