Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Laroche

GDI Transparentblt

This topic is 5854 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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)

Share this post


Link to post
Share on other sites
Advertisement
create a mask for your sprites, and do the transparency yourself using bitblt and the proper raster ops (last argument).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!