Okay, so I have decided to make a simple card maker. The program will 'ideally' allow its user to load a picture from their c drive and it will allow them to change different images while the loaded picture stays the same.
The Problem: I decided to use picture boxes but the problem is picture-boxes are square and in some cases I am using hexagons. So perhaps its transparency I am having the trouble with bu cause my images were made in MS paint.
If anyone has been down this road and can help me with either a new direction to approach this or any easy solutions...feel free. Thanks again for reading.
Using Images as layers... or perhaps Transparity
Page 1 of 19 Replies - 1682 Views - Last Post: 31 July 2012 - 01:13 PM
Replies To: Using Images as layers... or perhaps Transparity
#2
Re: Using Images as layers... or perhaps Transparity
Posted 30 July 2012 - 06:33 PM
To paint into irregular shapes, you can use the overloads on Graphics.SetClip() that take GraphicsPaths or Regions. Here's the documentation for the flavor that takes a path: http://msdn.microsof...ibrary/0z994t06
Now your question from the other thread about the "opaque form" is starting to make a little bit of sense. You had the right paradigm of have containers that can hold things, lets you move them around, a paints when you tell them to. Unfortunately, the choice of using the Form control and other WinForm controls is probably not the best choice to implement the paradigm. You will probably be better off implementing something to hold a list of images to be rendered and calling Graphics.DrawImage().
If you really need some transparency effects, there are overloads of Graphics.DrawImage() that take an ImageAttributes parameter. In the ImageAttributes class, you can set color keys for transparency effects.
Now your question from the other thread about the "opaque form" is starting to make a little bit of sense. You had the right paradigm of have containers that can hold things, lets you move them around, a paints when you tell them to. Unfortunately, the choice of using the Form control and other WinForm controls is probably not the best choice to implement the paradigm. You will probably be better off implementing something to hold a list of images to be rendered and calling Graphics.DrawImage().
If you really need some transparency effects, there are overloads of Graphics.DrawImage() that take an ImageAttributes parameter. In the ImageAttributes class, you can set color keys for transparency effects.
#3
Re: Using Images as layers... or perhaps Transparity
Posted 30 July 2012 - 07:50 PM
ok to use this:
I would need to create a class with a GraphicsPath Method? What type of information would I need to provide in that Method to get my desired effect?
private void SetClipPath(PaintEventArgs e)
{
// Create graphics path.
GraphicsPath clipPath = new GraphicsPath();
clipPath.AddEllipse(0, 0, 200, 100);
// Set clipping region to path.
e.Graphics.SetClip(clipPath);
// Fill rectangle to demonstrate clipping region.
e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
I would need to create a class with a GraphicsPath Method? What type of information would I need to provide in that Method to get my desired effect?
#4
Re: Using Images as layers... or perhaps Transparity
Posted 30 July 2012 - 08:38 PM
GraphicPath there is a class that is already implemented by the framework. To do your hexagon, you'd probably have to call AddPolygon() and pass in the points of your hexagon.
#5
Re: Using Images as layers... or perhaps Transparity
Posted 30 July 2012 - 08:50 PM
hmm.... perhaps I don't have a using statement I need. I keep getting this:
I have: using System.Drawing;
Error 1 The type or namespace name 'GraphicsPath' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Tailean\Documents\Visual Studio 2010\Projects\MyCCG\MyCCG\Form1.cs 26 13 MyCCG
I have: using System.Drawing;
This post has been edited by Tailean: 30 July 2012 - 08:52 PM
#6
Re: Using Images as layers... or perhaps Transparity
Posted 30 July 2012 - 09:02 PM
Good instincts there. You should follow them more often.
To help you follow your instincts, it often pays to look at the documentation. In this case, you're having a problem with GraphicPath. Looking in MSDN, we get to the class documentation page: http://msdn.microsof...2d.graphicspath
If you look near the top it says:
To help you follow your instincts, it often pays to look at the documentation. In this case, you're having a problem with GraphicPath. Looking in MSDN, we get to the class documentation page: http://msdn.microsof...2d.graphicspath
If you look near the top it says:
Quote
Namespace: System.Drawing.Drawing2D
Assembly: System.Drawing (in System.Drawing.dll)
Assembly: System.Drawing (in System.Drawing.dll)
#7
Re: Using Images as layers... or perhaps Transparity
Posted 31 July 2012 - 01:16 AM
In these 2 lines:
Could you tell me what the numbers stand for? (0, 0, 200, 100) 0, 0, 500, 300. I know that's probably a very basic question..I am just unsure..i never worked with this before.
private void SetClipPath(PaintEventArgs e)
{
clipPath.AddEllipse(0, 0, 200, 100);
e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
Could you tell me what the numbers stand for? (0, 0, 200, 100) 0, 0, 500, 300. I know that's probably a very basic question..I am just unsure..i never worked with this before.
#8
Re: Using Images as layers... or perhaps Transparity
Posted 31 July 2012 - 04:48 AM
I believe IntelliSense will confirm, but it should be the 4 parameters to define a rectangle: x,y,width,height (where x + y denote the upper-left corner of the rectangle).
EDIT: Just checked the documentation and was correct. You can also pass in an existing Rectangle or RectangleF object.
GraphicsPath.AddEllipse() on MSDN
EDIT: Just checked the documentation and was correct. You can also pass in an existing Rectangle or RectangleF object.
GraphicsPath.AddEllipse() on MSDN
This post has been edited by MrShoes: 31 July 2012 - 05:03 AM
#9
Re: Using Images as layers... or perhaps Transparity
Posted 31 July 2012 - 12:42 PM
Please learn to search the MSDN before you ask these questions. Each of these has been answered by referencing the documentation, as shown by the posters. I'm not trying to be harsh, since I know you're fairly new to this, but the documentation is your best friend. Learn to love it. Learn to use it, and you won't be at the mercy of some forum people's free time.
#10
Re: Using Images as layers... or perhaps Transparity
Posted 31 July 2012 - 01:13 PM
I hear you, and I did look it up..however...I didn't understand still that's why I asked the question.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote





|