-1

I have an application using png type and GIF with transparency in the background. So I want to display them in Winforms using PictureBox, but they still have the outline or something outside the images that seem unclear as photoshop does. I have attached the example below.

enter image description here

enter image description here

As you guys can see the image has something outside that looks so annoying, can you guys help me figure out how to fix or improve It? I appreciate that.

Below is the original png that I used in my project

enter image description here

  • 1
    Anything that is displayed there is not `DimGray`. Those pixels may look transparent to the naked eye but they are obviously not completely so. Only pixels that are completely transparent in the image will allow the background colour to show through completely and thus be made transparent in the form. – jmcilhinney Feb 17 '23 at 05:29
  • If you can't change the images to be fully [transparent](https://stackoverflow.com/questions/33189112/remove-the-black-background-color-of-a-bitmap/33191068?r=SearchResults&s=1%7C22.9449#33191068) all around (and inside) you'll have to livr with the fact that Winforms is not well suited for this task. More modern targets can do it, though. – TaW Feb 17 '23 at 07:44
  • @jmcilhinney I already tried to change the DimGray to Transparent, but It still did not work. do you have any example that is relative to my problem? – BlackHeart1408 Feb 17 '23 at 09:16
  • @TaW so the png images that I used were fully clear in transparent mode, but I don't know why It still shows like that – BlackHeart1408 Feb 17 '23 at 09:17
  • It must be because some pixels are only semi-transparent. You need to get rid of those if you want to avoid those ugly artifact in Winforms. My link show how to do that, but the images will change and get less smooth. – TaW Feb 17 '23 at 11:07
  • [Transparent background image for Form - Smooth edge shape for the Form](https://stackoverflow.com/a/33531201/3110834) – Reza Aghaei Feb 17 '23 at 14:27

1 Answers1

0

The problem is that the image is not fully transparent where you think it is.

The problem when taking an image and removing the background with transparency is that you often use the magic wand and it works for 99% but the rest you have to fix manually.

What I personally prefer in these cases is that you take your image (the png version with transparency) then in Photoshop you add another layer and put the first layer with the image on top. Then you change background color on the second layer (the one you just created) with a strange color in regards to the image, so in this case i would test with yellow.

Then if you have everything correct you should not see your image and since part of it is transparent you will see the yellow color where the image is transparent. Now you can zoom in and check the "strange parts" of the image and then you will find the spots that are not transparent. Now you can use the eraser or magic wand and polish the edges so that you only see yellow where it should be transparent. When you are done you could test and change the yellow color on the second layer to red and just double check. Then it will probably work as a charm. Good luck! If it does not work after that, please give us more details and also add the png image.

MrApnea
  • 1,776
  • 1
  • 9
  • 17