Image without background on winform - c#

How can I have an image without background on a winforms application.
So that you only can see the image, without a form or something.
I now tried to set the Background Color and Transparency key to the same color but that results to this:
I also search the web but I didn't found really usefull answers...
So is there another way to do this?
Thanks in advance

Try using png with transparency for image and real transparency for the form by overriding CreateParams to allow transparency.
Provlem on your screenshot is caused by mixing original background color with image. After mixing the color doesn't match transparency key, so you get such border.
The other solution can be to draw the image having no transparency without scaling and antialiasing.

Related

Transparent picturebox

I'm trying to add an icon to a Win Forms project, but I can't get the transparency working. I've tried with several different images but I'm not able to set the background color to blue.
What am I doing wrong?
Change back color of picturebox to Color.Transparent.
You can also try to use png file with transparency channel.
The PictureBox is transparent, you need to use a transparent image (such as a PNG), as already stated.

Black in my picturebox c#

when I use an image to a URL in my picture box I have black in here
Image = http://prntscr.com/cx1nre
I am known it's because my panel is on Highlight but when I use " Transparent " it give me a black in my picture box... example = http://prntscr.com/cwu9ev
Anyone can help me please?
After understanding your question (one picture over other and the top with transparency), your problem is how .net transparency works, it's not real transparency, it copies the background of the container.
So, to make it work instead of two picture boxes add a panel and a picturebox inside the panel, set the backgroundimage of the panel to the image you wanted to use, and then set the overlay image on the picturebox. As .net copies the container's backgrond, as you added the picture box as a child of the panel the picture box will copy the image and the transparency would work as you expected.
Only caveat is that you need to load manually the image, but there are plenty of examples on how to load it.
Also, there's even a better approach: instead of two pictureboxes just add one, load into a Bitmap the background you want, retrieve a Graphics object from it, draw the second image with Graphics.DrawImage and then use the bitmap as the Image for the picturebox. It's more complicated but it's the most efficient way to do this.

Form With customized Borders and Transparent Background [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Transparent images with C# WinForms
I am coding an app which will have a No Border. It will also have a BackgroundImage[which would be displayed as a slideshow; changed with a timer].
Sample Image [you may need to download this to experience the transparency] :
I have tried the following two methods to accomplish this :
Using WindowsFormsApplication :
I used the TransparencyKey property of the Form along with setting the same Background Colour.[I used Fuchsia]. Now some of the pixels in the border had the colour Fuchsia.
Using WindowsPresentationFoundation :
I used the AllowsTransparency of the Window and set the Background to the Image and the image was displayed correctly with transparency. Now I have to add another image at a point [by setting the margin] which i noted before in Paint.
For Example : I had the image cropped from the original background and then i have place it in the correct place in the form by setting the margin noted before.
But this causes to set a wrong margin!
Update :
In WPF, If I use the BackgroundImage in the Grid, it solves the margin problem but the Transparency just does not work and makes the transparent regions white!
Please give some hints to get out of this problem!
It is a problem caused by the image. You can see it when you load it in, say, Paint.NET and zoom in so you can see the individual pixels. The upper left corner looks like this:
Note how the pixels on the edge are partially transparent. So if you draw this image on top of a background of, say, Fuchsia then those edge pixels are no longer gray, they blend with the background and produce a different color. Which no longer matches the TransparencyKey so the video adapter won't filter them. You'll see them as a fringe of various shades of magenta.
You'll need to edit the image to give it a "hard" edge without any transparency.
In WPF window:
WindowStyle=None
AllowsTransparency=True
Background=Transparent
And then put an image with your content doesn't work?

How to colour a transparent part of an image programmatically in .NET

I have an image created and saved manually as a file, which has a shape (e.g. a heart) that is transparent in the image, and the rest of the image has other colour. How to make the transparent shape with a specified colour programmatically in .NET, leaving the rest of the image untouched?
For example, provided is an image, which I want to fill transparent part with a colour.
http://www.sendspace.com/file/an53a1
It's transparent. So draw the background first in the color you want with Graphics.Clear(), then Graphics.DrawImage() to draw the image.
What you need is a flood fill algorithm.
Please take a look at this:
http://www.codeproject.com/KB/GDI-plus/floodfillincsharp.aspx

How to make any control shape irregular in c#

how to make any control of win application transparent. i want that i will assign a background image for the target control and will invoke a routine and that routine will create that control transparent in such a way that only image will visible. as a example suppose image has assign to picture box. the picture shape is not square rather irregular. if i can make picture box transparent then user will see the image only. basically i want to make a picture box or any control irregular shape. how to achieve it through code in c#.
thanks
In WPF, transparency is quasi for free. For the image-element, assign a png-image with an alpha mask and the image will be rendered with active transparency.
For controls with an solid background, you generally have to set the Background to a transparent Brush:
If you want to make a whole window partial transparent, you have to remove the border, set the window style to none, set the background brush to a transparent brush, and set the AllowsTransparency-property of the window to true.
there is one for ordinary winform at
http://www.youtube.com/watch?v=K_JzL4kzCoE

Categories