GDI Transparentblt

Started by
6 comments, last by Laroche 21 years, 4 months ago
Using GDI''s transparentblt function (i think that''s what it''s called) I''ve managed to get transparent tiles and multiple layers working with my level editor fairly well. However, there is one problem: it is HORRENDOUSLY slow! Also, the webpage/example i learned it from (gametutorials.com) mentions that it has a huge memory leak in Win 95/98. Is there any replacement for this function? Unfortunately the design was not made with the idea of NOT using GDI (it was a learning process for me) so i really dont feel like re-engineering the entire app to support DirectDraw just for this silly problem. I''d be (almost) eternally grateful for any assistance. (im sure using a lot of brackets)
Check out my music at: http://zed.cbc.ca/go.ZeD?user_id=41947&user=Laroche&page=content
Advertisement
create a mask for your sprites, and do the transparency yourself using bitblt and the proper raster ops (last argument).
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
Yep. What he said. Make a bitmask, and then call BitBlt twice, once on the bitmask with SRCAND, and then on the bitmap with SRCPAINT.
alright thanks!
Check out my music at: http://zed.cbc.ca/go.ZeD?user_id=41947&user=Laroche&page=content
Don''t forget Winprog!


The hackers must have gotten into the system through the hyperlink!!
Invader''s Realm
i''m curious as to why the gametutorials article said there would be a memory leak on 95/98? that function isn''t even supported on 95 and on very few 98 device drivers that i''m aware of.
Forget the masks, that''s brutal Instead use image lists like I do:D Way simpler. The leak is true I''ve run into it when I desparately searched for transparent technique. GDI+ has perfect transparency, no leaks, I''ve played with it but am using MFC and don''t want to use two apis for gfx so I dumped GDI+. Though it''s pretty cool as it opens up some image formats other than bmp plus it''s C++ based and we know OOP is second coming and is the bomb, yes?
Ok i completely fixed the problem using the suggestion that I use masks. I made it completely transparent too, by adding another member in my CBitmap class (HBITMAP hMask), and creating the mask inside of the load member function using a private member function CreateMask (the one supplied in Winprog, thanks for the link!). I replaced the implementation of transparentblt with the new way of bltting, and PRESTO! it worked first shot! about 15-20 minutes of re-designing and coding, and everything works flawlessy. thanks again guys!
Check out my music at: http://zed.cbc.ca/go.ZeD?user_id=41947&user=Laroche&page=content

This topic is closed to new replies.

Advertisement