Two quick solutions for doing masking (without changing PF):
1. Use multiple blits with different masks
A. Make a copy of your original image surface:
Surface* temp = image->Clone();
B. Blit your B&W mask onto temp using white as colormask:
mask->SetColorMask(Color(255,255,255));
Surface* old_target = display->SetRenderTarget(temp);
display->Blit(0,0,mask);
C. Blit your temporary image to the screen, now containing a lot of black pixels to be masked away.
temp->SetColorMask(Color(0,0,0));
display->SetRenderTarget(old_target); (passing NULL or 0 as argument will default to the backbuffer so that would work for us also)
display->Blit(x,y,temp);
D. Don't forget to free the temporary surface if it is no longer needed (but if you keep doing this in a loop you will benefit from reusing the temporary surface by blitting the original image on top of it).
2. Loop over each pixel and do your masking (this could be extended to more than just on/off masking)
- Code:
Rasterizer* imgrast = display->CreateRasterizer(image);
Rasterizer* maskrast = display->CreateRasterizer(mask);
for (int y=0; y<image.GetHeight(); y++)
for (int x=0; x<image.GetWidth(); x++)
if (maskrast->GetPixel(x,y) == Color(255,255,255))
display->SetPixel(x,y,imgrast->GetPixel(x,y));
Please bare in mind that I have NOT compiled this since I'm currently on a linux platform so this might not compile if you just copy-past it. And even if it does, there is no guarantee that it will actually work (i.e. produce the wanted effect). Possibly you will need to lock (and then unlock) the surface before doing the SetPixel(). Why post it then you might ask? Well, it can serve as a direction of what I think is possible just looking at the declaration of PF.
Please let me know if this works and which of my two solutions is faster since I'm interested in the results even though I'm not currently coding anything for the PPC.