flat assembler
Message board for the users of flat assembler.
Index
> Windows > Drawing Transparent Bitmaps |
Author |
|
calpol2004 07 Jan 2006, 12:59
sorry if this is in the wrong forum it fits into ASM and Higher level languages so i wasnt 100% sure where it shud go. in my application i draw a picture of a gear, unfortunatly because bitmaps are infact square the background of the picture does not match the background of the window. Ive been using the www.winprog.org which however written C up till now the code has been fairly easy to port over to ASM, however to make the background of the image i need to make a mask then overlap and stuff .etc .etc however im rly havin trouble porting the code below, if ne body could help me port this code or show me an example of an image being drawn on a window or dialog and having the background color transparent:
Code: HBITMAP CreateBitmapMask(HBITMAP hbmColour, COLORREF crTransparent) { HDC hdcMem, hdcMem2; HBITMAP hbmMask; BITMAP bm; // Create monochrome (1 bit) mask bitmap. GetObject(hbmColour, sizeof(BITMAP), &bm); hbmMask = CreateBitmap(bm.bmWidth, bm.bmHeight, 1, 1, NULL); // Get some HDCs that are compatible with the display driver hdcMem = CreateCompatibleDC(0); hdcMem2 = CreateCompatibleDC(0); SelectBitmap(hdcMem, hbmColour); SelectBitmap(hdcMem2, hbmMask); // Set the background colour of the colour image to the colour // you want to be transparent. SetBkColor(hdcMem, crTransparent); // Copy the bits from the colour image to the B+W mask... everything // with the background colour ends up white while everythig else ends up // black...Just what we wanted. BitBlt(hdcMem2, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY); // Take our new mask and use it to turn the transparent colour in our // original colour image to black so the transparency effect will // work right. BitBlt(hdcMem, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem2, 0, 0,SRCINVERT); DeleteDC(hdcMem); DeleteDC(hdcMem2); return hbmMask; } |
|||
07 Jan 2006, 12:59 |
|
FrozenKnight 07 Jan 2006, 13:36
http://www.winprog.org/tutorial/transparency.html
try taht site it's in C but C isn't that hard to convert to ASM |
|||
07 Jan 2006, 13:36 |
|
calpol2004 07 Jan 2006, 18:28
ive got it to kind of work thou the picture displayed is "chalky" and not like the 32bit picture i embedded in the program it seems to be displayed as something like a 256color picture. heres the package so u can see for ure self. Im absolutely baffled and ive been doin this all day. hopefully somewhere in ure pool (in my case a puddle) of knowledge u know how to do this properly. any help appreciated.
the invertedpic.bmp file is the inverted picture, its inverted bcus basically it dusnt work otherwise . the watitshudbe.bmp is the picture of wat it looked like before i inverted it (i didnt lose quality by inverting it, i can invert invertedpic again and it comes out how it shud be). PS:the password is "password", if u get it right the dialog disappears if u dont u get a message telling u so. not relavent but just added this ne way.
|
|||||||||||
07 Jan 2006, 18:28 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.