Copy bitmap with mask

7 posts / 0 new
Last post
jwanderson88
jwanderson88's picture
Offline
Last seen: 2 years 1 week ago
Joined: 2019-04-13 19:29
Copy bitmap with mask

This is a happy camper! I finally succeeded in copying a bitmap to another bitmap on a 24-bit screen while protecting parts of the destination bitmap with a mask. This is something I needed for my game Blackfang, which I am currently working on. It had brought progress on the game to a halt. I couldn't find a way to write to a single non-interleaved bitplane. I didn't ask because I didn't think anybody had tried it for a few decades. I finally found a way to create the mask by "brute force". Then I used BltMaskBitMapRastPort to do the copy. I plan to write a short article describing how to do it. And what not to do. I like to help people when I can. I need to get a deeper understanding of the process first. If anybody on the forum has actually done it, I'd like to learn more about it. I'm pretty sure there will be somebody to tell me how easy it is.

thomas
thomas's picture
Offline
Last seen: 3 months 1 week ago
Joined: 2011-05-16 14:23
Re: Copy bitmap with mask

I couldn't find a way to write to a single non-interleaved bitplane.

  1. void draw_to_bitplane (PLANEPTR bitplane,int width, int height)
  2.  
  3. {
  4. struct RastPort rp;
  5. struct BitMap bm;
  6.  
  7. InitBitMap (&bm, 1 ,width ,height);
  8. bm.Planes[0] = bitplane;
  9.  
  10. InitRastPort (&rp);
  11. rp.BitMap = &bm;
  12.  
  13. SetRast (&rp,0);
  14. SetAPen (&rp,1);
  15. DrawEllipse (&rp, width / 2, height / 2, width / 2 - 1, height / 2 - 1);
  16. }
jwanderson88
jwanderson88's picture
Offline
Last seen: 2 years 1 week ago
Joined: 2019-04-13 19:29
Re: Copy bitmap with mask

That works great. Thanks a lot. There is more I need to do. Now I need to blit a 24-bit black and white image to the one bit-plane image. Is there some way to mash a 24-bit image down to 1 bit? Can you copy a 24-bit image to an 8-bit CLUT image? That would get me halfway there.

thomas
thomas's picture
Offline
Last seen: 3 months 1 week ago
Joined: 2011-05-16 14:23
Re: Copy bitmap with mask

cybergraphics.library has an ExtractColor function which should do what you need.

jwanderson88
jwanderson88's picture
Offline
Last seen: 2 years 1 week ago
Joined: 2019-04-13 19:29
Re: Copy bitmap with mask

That works great. Making masks is what ExtractColor was made for. Thanks Thomas. You were a huge help. I'm still going to write something about my mask work. There is hardly any information about cybergraphics.library. The autodocs on the subject are almost non-existent. I did find some information for Aros. I imagine the functions work the same.

thomas
thomas's picture
Offline
Last seen: 3 months 1 week ago
Joined: 2011-05-16 14:23
Re: Copy bitmap with mask

Cybergraphics.library is not really a part of AmigaOS 4. The RTG system of OS4 is based on Picasso96. The cgx library in OS4 is only a wrapper which forwards cgx calls to P96.

The autodocs for cybergraphics.library are in the cgx dev archive: http://aminet.net/package/dev/misc/CGraphX-DevKit

hypex
hypex's picture
Offline
Last seen: 3 months 3 weeks ago
Joined: 2011-09-09 16:20
Re: Copy bitmap with mask

I found datatype objects can help. Things like the Intuition classes would help as well. To keep code as generic as possible.

For example, you can load in game assets, like images and have the OS sort out the internals. By making use of datatypes to load them in. The system sorts it out and give you an object pointer.

You can then use this with Intuition functions and grab the bitmaps which you can then use directly with graphics.library in blitter functions. I've tested this on OS4 and 68K. It can work well to keep code portable across different graphics hardware.

Log in or register to post comments