I am working on album designing s/w. I have 2 overlapped pictureboxs. My problem is how to make white portion of mask as fully transparent and black portion semi transparent. I will put this type of mask on 1 picturebox.
Transparent mask on picturebox.
Collapse
X
-
Tags: None
-
Are you thinking that by masking the images, your overlapping picturebox controls will become transparent and allow you to see through one picturebox to the one below it? They don't work that way. If the image is transparent it will allow you to see through... to the background color of the picturebox but no further. -
Have u seen Karizma s/w for album designing? In karizma there is 2 overlapped pictureboxs, mask which is transparent on 1 picturebox and photo is on another. It shows the back side picturebox, which contains photo. In my s/w ,when i overlap the two picturebox, i can't see the back side picturebox even the front picturebox contains transparent image. It shows background image of panel on which i have added this pictureboxes. How it is possible in c#.net?Comment
-
No. And every google for it takes me to some FreeSoftwareTop ShareDownload kind of site. Since I'm not a fan of viruses I'm not going to download it.Have u seen Karizma s/w for album designing?
From what you describe they are not using a basic Windows.Forms.C ontrols.Picture Box control. They created a custom control for their needs.
There is also no LEDnumber or DashSpeedometer Guage in the basic Framework. But you can make them.Comment
-
-
Custom controls are far from a novice subject.
They generally involve- overriding the OnPaint method and writting your own drawing routine.
- Creating custom events. In the same way a button has a .Click event, your control needs its own events in most cases.
- Creating custom properties. In the same way a button as a .Width property, your custom control will need properties specific to it's purpose.
There are a couple tutorials here that will get you started. Once you have mastered making custom controls based on pre-existing components then you can move on to custom drawing.
Custom events - A practical guide
Buiding an application - Part 1Comment
-
-
I have tryed my level best. But result is zero. Because when i add this control it always takes background color of parent control even if it contains transparent image.
If u have any idea then pls tell me.Comment
-
This is coding of Custom Control. After that i add this user control in Panel.Code:public event PaintEventHandler ent; private Image Img; public Image imgData { get { return Img; } set { Img = value; } } private Image BackImage; public Image BackImg { get { return BackImage; } set { BackImage = value; } } private PictureBox px; public PictureBox pk { get { return px; } set { px = value; } } protected override void OnPaint(PaintEventArgs pe) { // Calling the base class OnPaint base.OnPaint(pe); if (imgData != null) { ent += new PaintEventHandler(CustomControl1_ent); px.Paint += new PaintEventHandler(px_Paint); pe.Graphics.DrawImage(Img, 0, 0); if (BackImage != null) { PaintEventHandler handele = ent; if (handele != null) { Graphics g = px.CreateGraphics(); px_Paint(px, pe); } // pe.Graphics.DrawImage(BackImage, new Rectangle(0, 0, px.Width, px.Height), 0, 0, BackImage.Width, BackImage.Height, GraphicsUnit.Pixel); } } } void px_Paint(object sender, PaintEventArgs e) { if (BackImage != null) { e.Graphics.DrawImage(BackImage, new Rectangle(0, 0, px.Width, px.Height), 0, 0, BackImage.Width, BackImage.Height, GraphicsUnit.Pixel); } } void CustomControl1_ent(object sender, PaintEventArgs e) { //if (BackImage != null) //{ // e.Graphics.DrawImage(BackImage, new Rectangle(0, 0, px.Width, px.Height), 0, 0, BackImage.Width, BackImage.Height, GraphicsUnit.Pixel); //} }
I don't know it is a better way or not. But i have tried in such way.Code:CustomControl1 cs = new CustomControl1; Panel1.Controls.Add(cs); and pass Image value to control.
Last edited by tlhintoq; Mar 8 '10, 02:22 PM. Reason: [CODE] ...Your code goes between code tags [/CODE]Comment
-
TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.Comment
-
From what I can tell your custom control is still based on a picturebox and as such, inherits all of it's limitations which you are trying to get away from.
I give you big marks for a great start and an attempt to do your own coding. This is head and shoulders above what most new posters do.
But what you are going to have to do is create a new control, not inherited from a picturebox, and do all of your own drawing. Not just calling the base.OnPaint method.
Like I said, it is no small matter. To be honest, it isn't the type of thing one figures out by wacking around with code. Apress publishing makes a 1,000+ page book on making custom controls in C#
ISBN 1-59059-439-8
"Pro .NET 2.0 Windows Forms and Custom Controls in C#"
US$ 49.99
I think this is your next best stepComment
Comment