I am working on a C # program that takes screenshots of a potion on a user's screen. For most users, it works as it should, but I recently ran into one problem. It seems that (at least) one pixel color that always looks transparent in the output image. Any instance of color # 0D0B0C (RGB 13, 11, 12) looks transparent in the saved png. This is with PixelFormat set to Format32bppArgb. If I set it to Format32bppRgb or Format24bppRgb format, the same pixel color will appear in black in the saved png.
I have no idea what could be causing this, but the only thing I could do to “fix” it was to clear the graphic object to that color before doing CopyFromScreen (). I do not want to do this, although for several reasons. Firstly, I don’t know if this is the only color that has a problem (there are a lot of possibilities with 16,777,216 colors), and secondly, I hate hack fixes, it looks like a hack fix.
Can anyone shed some light on what might cause this problem? I got confused with PixelFormat in creating a bitmap and using the CopyPixelOperation method in the CopyFromScreen method nothing works. The fact that clearing the graphic object from this color “corrects” seems to tell me that the transparency comes from the screen data itself, but that doesn't make sense. I have been looking at this for too long, I think I need a new perspective. If anyone knows why this could happen, I'd love to hear it. Thanks.
source share