C# transparent form causes image to have ugly borders - c#

I have a transparent form in C# and on top of the form I have a splashscreen picturebox with an image. The form's backcolor is actually just Control gray. I also just set the form's transparencykey to Control gray as well. I used the tutorial here to make the form transparent: How to design a cool semi transparent splash screen?
The image is stretched over the picturebox to make it fit nicely on all computer screen resolution. Here is the original image, notice that it has a transparent left side with squares which does not have any borders.
OriginalImageInPhotoshop
However afterwards, the form has these ugly borders on the left side of the image that are the same color as the backcolor & transparencykey (in this case, Control gray). If I place the form over a black background, you can quite visibly see this. How can I get rid of this?
Problem
So far, only remedies I have found is to either not have the image set to stretch in the picturebox (but that would cause it to appear different on every computer screen!) or perhaps theres another way to make a form transparent...

Related

How to make a clickable, transparent, and borderless form?

I'm trying to place a transparent and borderless child (WinForm) form on top of another child (WinForm) form that is opaque, but I'd like to retain the ability to directly click on the transparent form. There are a few answers on the web regarding making a transparent form that can be clicked through, but I want to make one that I can click on.
I've found this answer, which shows that setting my transparent form's BackColor and TransparencyKey to something specific like Color.Red achieves the desired behavior. However based on this answer, it seems this behavior between certain Colors and TransparencyKey may actually be a long-running bug.
Ideally I don't want to rely on a bug to achieve a desired effect. What would be a more "appropriate" approach for making a clickable, transparent, and borderless (WinForm) form?
Update (Additional Context):
I'm basically creating a screen pixel previewer for color data extraction.
Overlay forms containing captured bitmap(s) of the screen area.
Another form that gives a visual indicator for the pixel area being previewed (small black box in the below snapshot). This form is placed above the bitmap forms. I have this form as transparent (to see through to the below bitmaps), but I still want to be able to click on it for event processing.
Without the TransparencyKey = BackColor = Color.Red trick, clicking within the small black box causes focus to move to the below bitmap form, which then covers up the small box form and the preview window showing the zoomed view. The purpose of the click is to capture the cursor position for additional processing. I can work around this by immediately giving focus back to the small box + preview forms, but that occasionally causes flicker.

Semi transparent control on a transparent form

I have a transparent form, on which I need to place a semi-transparent panel. I've gotten the panel to be semi-transparent relative to the form's color, but whenever I set the form to transparent, that semi transparency stops working. It seems it is only blending the color with the color of the control behind it, but when the form is transparent it doesn't do so with any windows that may be behind the form.
Is there any way this can be achieved? I'm not sure if I should be overwriting the form's paint method, the control's, or both.
Any help is appreciated! Thanks!

How can I create a transparent System.Windows.Forms.Panel on top of two other already existing Panels then draw a line on my transparent panel?

I'm writing a form in C# and have several panels. I need to draw a line between two of the panels. I've found online several ways to go about this, the most promising appears to be to create a third panel, make it transparent, place it on top of my original panels and draw the line here.
I'm not able to get the panel to be transparent, even if I set its BackColor and ForeColor properties to transparent (in code or in design view of VS).
Any ideas on how to make the panel itself transparent (or not Visible) but have the line I draw on it still visible on top of everything else?
Thanks in advance.
No, it's transparent. See this by giving the form's BackgroundImage a value. You'll see it through the transparent panel. Of course, that's not the kind of transparency you want, you want stacking effects to work. There is no direct support for that.
If you want layers to work then don't use controls. Use the Paint event to draw. Now there's no problem, if you want transparency then just don't paint. Draw a line across an image simply by drawing the image first. This is also the rendering model of WPF.
You can actually do this pretty easily as your own UserControl. Here's a code example:
Drawing on top of controls inside a panel (C# WinForms)
This is similar to what you were originally attempting to do, only instead of drawing a line on top of a transparent panel, this code creates an irregularly-shaped user control (which happens to be in the irregular shape of a line).

How do I scrape what a transparent panel shows into a bitmap?

Question:
How do I scrape what a transparent panel shows into a bitmap?
Background:
I need to make a form that sits on top of everything and blurs part of the screen but doesn't stop the user from interacting with it. Odd... I know.
I created a form and added a panel to it. I then set the set background color of the panel to red. Then set the form's TransparentKey property to red and topmost = True.
So now I have a transparent panel. Cool. I can interact with the app below it. Cool. Now I just need to add the blur. I would like to take what is showing on panel1 and blur it then display on panel2 that sits over the top of panel1. Or at least that is the idea.
Important detail:
DrawToBitmap() just shows the red background.
This is running on XP.
Yes, DrawToBitmap(). But not on the transparent panel, on the one that's underneath it. If that 'panel' isn't actually yours then you have to use Graphics.CopyFromScreen().
Not sure what you intend to do with it, but drawing the blurred image in the transparent panel will make it non-transparent and you cannot interact with the underlying window anymore. Also, don't use Red, you'll get unintended transparency if the underlying window contains any red. Color.Fuchsia is a good choice, it is a fuchsed-up color.

Setting my PictureBox to transparent background color doesn't really make it transparent. Bug?

Here's what I have in VERY simple easy to grasp terms.
My form background is Blue.
I created a gradient image from white to the Blue from the form background. This is to give the form a nice gradient look. I added a picturebox to my Form and set this image as the Image.
I added a picturebox with a Logo on top of the gradient Picturebox, but it's 'grabbing' the Form background color and not respecting the transparent background image I wanted it to grab.
So:
Blue Form -> Huge pictureBox with gradient -> Small picturebox thats supposed to respect the gradient.
Help please!
I think this might be as the PictureBox is not a control container. So this implies that when you drag the button picture box onto the main picture box, it is not actually a child of the picturebox, but rather of the form.
You would notice that if you were to do he same with a panel (set the form blue, panel background image, and place the button picture box control on the panel) it would show transparent to the panel control.
Why not rather set the Form BackgroundImage, avoid the Huge Picture Box, and set the small picture box on the form itself.

Categories