0

I'm trying to create a form which contains a PictureBox containing a PNG with a transparent background. So far, I've gotten pretty close by setting the BackColor and TransparencyKey to the same color, which isn't one present in the PNG. However, there does seem to be a fuzzy outline around the PNG which takes on the color used for the background and transparency. I did try with a PNG I got off the internet, to make sure it wasn't just my images, but the result was the same.

Is there any type of image processing I can do, or adjustments that can be made to the PictureBox, to mitigate this effect?

  • 1
    Could you provide a screenshot, please? You can easily take it with [Ctrl] + [Win] + [S] and then just paste it into the edit box here. Also what's the exact `BackColor` you are using? – Good Night Nerd Pride Nov 08 '21 at 13:16
  • 1
    @GoodNightNerdPride Sure, I'll edit it in in a second. As far as I can tell, it occurs with any color for the background. – James Ehrlinger Nov 08 '21 at 13:28
  • So it looks like you are using #00FF00 (green) as `BackColor` and `TransparencyKey`? – Good Night Nerd Pride Nov 08 '21 at 14:20
  • @GoodNightNerdPride Yes, but it also occurs with white and mediumPurple. – James Ehrlinger Nov 08 '21 at 14:47
  • 1
    See [Your image has semi-transparent pixels](https://stackoverflow.com/a/43373628/14171304). In case you just need a [PerPixelAlphaForm](https://stackoverflow.com/a/33531201/14171304). – dr.null Nov 08 '21 at 17:54
  • 1
    You may need to gwet rid of any semii-transparent anti-aliasing pixels. [Here](https://stackoverflow.com/questions/43372549/remove-outline-from-image-on-transparent-form/43373628#43373628) is a function to do that. – TaW Nov 08 '21 at 18:18
  • @TaW I've been trying to get your solution to work with my images, but I haven't had any success, it doesn't seem to be affecting them at all. Do you have any idea why that might be? I don't know nearly enough about image processing to trouble shoot this myself. – James Ehrlinger Nov 09 '21 at 14:55
  • Your image seems to be gone now. You should show us the code yopu tried. – TaW Nov 09 '21 at 16:11
  • @TaW Ah, sorry about that. I'll rehost them. I'm using an unmodified version of your UnSemi function, which operates on fields containing bitmaps of the images. I'll link one of the images below if you want to test it yourself. PNG - https://litter.catbox.moe/6l9j37.png Effect - https://litter.catbox.moe/1c61zi.PNG – James Ehrlinger Nov 09 '21 at 16:32
  • The 1st image still contains aliased pixels with an alpha of 33-88% or so. After applying the function to the image these ought to be all either a=0% or a=100% and then the frame should disappear. – TaW Nov 09 '21 at 19:08
  • @TaW Yes, I inserted the function call shortly after the bitmap for that image is made. What you're seeing is the resultant bitmap. Looking at the example you supplied, I see that you're using an image casted to a bitmap as a parameter. Would passing it a bitmap instead be a cause for concern? – James Ehrlinger Nov 09 '21 at 20:00
  • Do show the code you use! – TaW Nov 09 '21 at 20:19
  • @TaW here is the relevant code, https://litter.catbox.moe/4xiqwj.PNG . The field 'neutralEyesOpenMap' is later set as the image in the picturebox. – James Ehrlinger Nov 09 '21 at 20:30
  • Hm, is it actually set later? Changing a bitmap will not be picked up by the PBox without reloading it.. – TaW Nov 09 '21 at 20:37
  • @TaW Yes, I think so. Here is the update method, UnSemi is called in the makeMaps function, and the picturebox isn't updated until Loop is called. https://litter.catbox.moe/1znx27.PNG – James Ehrlinger Nov 09 '21 at 20:44

0 Answers0