Hello all,
Just a quick GDI+ related question for you all. I've three ellipses being
drawn in my game. I'm trying to smoothen the edges of them out using
anti-aliasing. Why is it that my puck (and neither of the paddles) is only
looking like it's been affected by this anti-aliasing, even though i apply
the SmoothingMode property before drawing anything?
See what i mean here: http://homepage.eircom.net/~basquill...tialiasing.JPG
And here's the code i used:
private void GameDraw(Graphics g)
{
// anti-aliasing
g.SmoothingMode = SmoothingMode.AntiAlias;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
CreatePaddle1Region();
CreatePaddle2Region();
CreatePuckPath();
// puck brushes
Brush puckBr = new SolidBrush(Color.Red);
g.FillPath(puckBr, puckPth);
puckBr.Dispose();
// paddle brushes
Brush paddleBr = new SolidBrush(Color.Black);
g.FillRegion(paddleBr, rgnPaddle1);
g.FillRegion(paddleBr, rgnPaddle2);
paddleBr.Dispose();
}
Many thanks in advance.
Brian 8 2373
First off a jpg is not really a good format to display a sample of anti-aliasing in as it is a lossy format. BMP would
be better as it is lossless. jpg will naturally introduce it's own distortions depending on the amount of compression
used.
Second if you are working with anti-aliasing make sure you turn off anti-aliasing and anisotropic filtering in your
video driver.
Remember it's the video driver that ultimately paints what you see on your screen. In this case you want to see exactly
what your application is doing, not what the video driver is doing for you. And I can't imagine any two users in the
universe having the same exact same video configuration. Unless that configuration of setting are likely to make your
application crash that is:) Then it seems as if the whole known universe stumbles upon them.
Once you get to a known base state come back and let us know what is happening. I will probably tinker around with this
some more tonight and I will let you know if I discover anything unusual.
--
....Carl Frisk
Anger is a brief madness.
- Horace, 20 B.C. http://www.carlfrisk.com
"Brian Basquille" <re**********@please.com> wrote in message news:%2****************@TK2MSFTNGP14.phx.gbl... Hello all,
Just a quick GDI+ related question for you all. I've three ellipses being drawn in my game. I'm trying to smoothen the edges of them out using anti-aliasing. Why is it that my puck (and neither of the paddles) is only looking like it's been affected by this anti-aliasing, even though i apply the SmoothingMode property before drawing anything?
See what i mean here: http://homepage.eircom.net/~basquill...tialiasing.JPG
And here's the code i used:
private void GameDraw(Graphics g) { // anti-aliasing g.SmoothingMode = SmoothingMode.AntiAlias; g.PixelOffsetMode = PixelOffsetMode.HighQuality;
CreatePaddle1Region(); CreatePaddle2Region(); CreatePuckPath();
// puck brushes Brush puckBr = new SolidBrush(Color.Red); g.FillPath(puckBr, puckPth); puckBr.Dispose();
// paddle brushes Brush paddleBr = new SolidBrush(Color.Black); g.FillRegion(paddleBr, rgnPaddle1); g.FillRegion(paddleBr, rgnPaddle2); paddleBr.Dispose(); }
Many thanks in advance.
Brian
First off a jpg is not really a good format to display a sample of anti-aliasing in as it is a lossy format. BMP would
be better as it is lossless. jpg will naturally introduce it's own distortions depending on the amount of compression
used.
Second if you are working with anti-aliasing make sure you turn off anti-aliasing and anisotropic filtering in your
video driver.
Remember it's the video driver that ultimately paints what you see on your screen. In this case you want to see exactly
what your application is doing, not what the video driver is doing for you. And I can't imagine any two users in the
universe having the same exact same video configuration. Unless that configuration of setting are likely to make your
application crash that is:) Then it seems as if the whole known universe stumbles upon them.
Once you get to a known base state come back and let us know what is happening. I will probably tinker around with this
some more tonight and I will let you know if I discover anything unusual.
--
....Carl Frisk
Anger is a brief madness.
- Horace, 20 B.C. http://www.carlfrisk.com
"Brian Basquille" <re**********@please.com> wrote in message news:%2****************@TK2MSFTNGP14.phx.gbl... Hello all,
Just a quick GDI+ related question for you all. I've three ellipses being drawn in my game. I'm trying to smoothen the edges of them out using anti-aliasing. Why is it that my puck (and neither of the paddles) is only looking like it's been affected by this anti-aliasing, even though i apply the SmoothingMode property before drawing anything?
See what i mean here: http://homepage.eircom.net/~basquill...tialiasing.JPG
And here's the code i used:
private void GameDraw(Graphics g) { // anti-aliasing g.SmoothingMode = SmoothingMode.AntiAlias; g.PixelOffsetMode = PixelOffsetMode.HighQuality;
CreatePaddle1Region(); CreatePaddle2Region(); CreatePuckPath();
// puck brushes Brush puckBr = new SolidBrush(Color.Red); g.FillPath(puckBr, puckPth); puckBr.Dispose();
// paddle brushes Brush paddleBr = new SolidBrush(Color.Black); g.FillRegion(paddleBr, rgnPaddle1); g.FillRegion(paddleBr, rgnPaddle2); paddleBr.Dispose(); }
Many thanks in advance.
Brian
Hello Brian.
The problem lies in the fact that you're filling a path in one instance and
a region in another. The path is a record of graphical elements designed to
enable you to store lines and shapes. The region is a collection of
rectangles that are primarily concerned with restricting pixel output to a
specific area of the drawing surface.
When paths are stroked or filled the objects used such as bushes or pens are
subject to the settings of the GDI surface. When a region is filled then the
system simply restricts output on a pixel by pixel basis according the othe
content of the region.
This effect is demonstrated in the following code.
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.SmoothingMode=SmoothingMode.AntiAlias;
GraphicsPath pth=new GraphicsPath();
pth.AddEllipse(10,10,300,200);
Region rgn=new Region(pth);
rgn.Transform(new Matrix(1,0,0,1,350,0));
e.Graphics.FillPath(Brushes.Black,pth);
e.Graphics.FillRegion(Brushes.Black,rgn);
rgn.Dispose();
pth.Dispose();
base.OnPaint (e);
}
If you want smoothing you will need to draw the paddles with a graphicspath
as opposed to a region.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"Brian Basquille" <re**********@please.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl... Hello all,
Just a quick GDI+ related question for you all. I've three ellipses being drawn in my game. I'm trying to smoothen the edges of them out using anti-aliasing. Why is it that my puck (and neither of the paddles) is only looking like it's been affected by this anti-aliasing, even though i apply the SmoothingMode property before drawing anything?
See what i mean here: http://homepage.eircom.net/~basquill...tialiasing.JPG
And here's the code i used:
private void GameDraw(Graphics g) { // anti-aliasing g.SmoothingMode = SmoothingMode.AntiAlias; g.PixelOffsetMode = PixelOffsetMode.HighQuality;
CreatePaddle1Region(); CreatePaddle2Region(); CreatePuckPath();
// puck brushes Brush puckBr = new SolidBrush(Color.Red); g.FillPath(puckBr, puckPth); puckBr.Dispose();
// paddle brushes Brush paddleBr = new SolidBrush(Color.Black); g.FillRegion(paddleBr, rgnPaddle1); g.FillRegion(paddleBr, rgnPaddle2); paddleBr.Dispose(); }
Many thanks in advance.
Brian
Hello Brian.
The problem lies in the fact that you're filling a path in one instance and
a region in another. The path is a record of graphical elements designed to
enable you to store lines and shapes. The region is a collection of
rectangles that are primarily concerned with restricting pixel output to a
specific area of the drawing surface.
When paths are stroked or filled the objects used such as bushes or pens are
subject to the settings of the GDI surface. When a region is filled then the
system simply restricts output on a pixel by pixel basis according the othe
content of the region.
This effect is demonstrated in the following code.
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.SmoothingMode=SmoothingMode.AntiAlias;
GraphicsPath pth=new GraphicsPath();
pth.AddEllipse(10,10,300,200);
Region rgn=new Region(pth);
rgn.Transform(new Matrix(1,0,0,1,350,0));
e.Graphics.FillPath(Brushes.Black,pth);
e.Graphics.FillRegion(Brushes.Black,rgn);
rgn.Dispose();
pth.Dispose();
base.OnPaint (e);
}
If you want smoothing you will need to draw the paddles with a graphicspath
as opposed to a region.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"Brian Basquille" <re**********@please.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl... Hello all,
Just a quick GDI+ related question for you all. I've three ellipses being drawn in my game. I'm trying to smoothen the edges of them out using anti-aliasing. Why is it that my puck (and neither of the paddles) is only looking like it's been affected by this anti-aliasing, even though i apply the SmoothingMode property before drawing anything?
See what i mean here: http://homepage.eircom.net/~basquill...tialiasing.JPG
And here's the code i used:
private void GameDraw(Graphics g) { // anti-aliasing g.SmoothingMode = SmoothingMode.AntiAlias; g.PixelOffsetMode = PixelOffsetMode.HighQuality;
CreatePaddle1Region(); CreatePaddle2Region(); CreatePuckPath();
// puck brushes Brush puckBr = new SolidBrush(Color.Red); g.FillPath(puckBr, puckPth); puckBr.Dispose();
// paddle brushes Brush paddleBr = new SolidBrush(Color.Black); g.FillRegion(paddleBr, rgnPaddle1); g.FillRegion(paddleBr, rgnPaddle2); paddleBr.Dispose(); }
Many thanks in advance.
Brian
Same thing I just discovered. Makes sense when you look at it close enough.
Doesn't anyone sleep around here?
--
....Carl Frisk
Anger is a brief madness.
- Horace, 20 B.C. http://www.carlfrisk.com
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message news:eE**************@TK2MSFTNGP12.phx.gbl... Hello Brian. The problem lies in the fact that you're filling a path in one instance and a region in another. The path is a record of graphical elements designed to enable you to store lines and shapes. The region is a collection of rectangles that are primarily concerned with restricting pixel output to a specific area of the drawing surface.
When paths are stroked or filled the objects used such as bushes or pens are subject to the settings of the GDI surface. When a region is filled then the system simply restricts output on a pixel by pixel basis according the othe content of the region.
This effect is demonstrated in the following code.
protected override void OnPaint(PaintEventArgs e) {
e.Graphics.SmoothingMode=SmoothingMode.AntiAlias;
GraphicsPath pth=new GraphicsPath();
pth.AddEllipse(10,10,300,200);
Region rgn=new Region(pth);
rgn.Transform(new Matrix(1,0,0,1,350,0));
e.Graphics.FillPath(Brushes.Black,pth);
e.Graphics.FillRegion(Brushes.Black,rgn);
rgn.Dispose();
pth.Dispose();
base.OnPaint (e);
}
If you want smoothing you will need to draw the paddles with a graphicspath as opposed to a region.
-- Bob Powell [MVP] Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article.
"Brian Basquille" <re**********@please.com> wrote in message news:%2****************@TK2MSFTNGP14.phx.gbl... Hello all,
Just a quick GDI+ related question for you all. I've three ellipses being drawn in my game. I'm trying to smoothen the edges of them out using anti-aliasing. Why is it that my puck (and neither of the paddles) is only looking like it's been affected by this anti-aliasing, even though i apply the SmoothingMode property before drawing anything?
See what i mean here: http://homepage.eircom.net/~basquill...tialiasing.JPG
And here's the code i used:
private void GameDraw(Graphics g) { // anti-aliasing g.SmoothingMode = SmoothingMode.AntiAlias; g.PixelOffsetMode = PixelOffsetMode.HighQuality;
CreatePaddle1Region(); CreatePaddle2Region(); CreatePuckPath();
// puck brushes Brush puckBr = new SolidBrush(Color.Red); g.FillPath(puckBr, puckPth); puckBr.Dispose();
// paddle brushes Brush paddleBr = new SolidBrush(Color.Black); g.FillRegion(paddleBr, rgnPaddle1); g.FillRegion(paddleBr, rgnPaddle2); paddleBr.Dispose(); }
Many thanks in advance.
Brian
Same thing I just discovered. Makes sense when you look at it close enough.
Doesn't anyone sleep around here?
--
....Carl Frisk
Anger is a brief madness.
- Horace, 20 B.C. http://www.carlfrisk.com
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message news:eE**************@TK2MSFTNGP12.phx.gbl... Hello Brian. The problem lies in the fact that you're filling a path in one instance and a region in another. The path is a record of graphical elements designed to enable you to store lines and shapes. The region is a collection of rectangles that are primarily concerned with restricting pixel output to a specific area of the drawing surface.
When paths are stroked or filled the objects used such as bushes or pens are subject to the settings of the GDI surface. When a region is filled then the system simply restricts output on a pixel by pixel basis according the othe content of the region.
This effect is demonstrated in the following code.
protected override void OnPaint(PaintEventArgs e) {
e.Graphics.SmoothingMode=SmoothingMode.AntiAlias;
GraphicsPath pth=new GraphicsPath();
pth.AddEllipse(10,10,300,200);
Region rgn=new Region(pth);
rgn.Transform(new Matrix(1,0,0,1,350,0));
e.Graphics.FillPath(Brushes.Black,pth);
e.Graphics.FillRegion(Brushes.Black,rgn);
rgn.Dispose();
pth.Dispose();
base.OnPaint (e);
}
If you want smoothing you will need to draw the paddles with a graphicspath as opposed to a region.
-- Bob Powell [MVP] Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article.
"Brian Basquille" <re**********@please.com> wrote in message news:%2****************@TK2MSFTNGP14.phx.gbl... Hello all,
Just a quick GDI+ related question for you all. I've three ellipses being drawn in my game. I'm trying to smoothen the edges of them out using anti-aliasing. Why is it that my puck (and neither of the paddles) is only looking like it's been affected by this anti-aliasing, even though i apply the SmoothingMode property before drawing anything?
See what i mean here: http://homepage.eircom.net/~basquill...tialiasing.JPG
And here's the code i used:
private void GameDraw(Graphics g) { // anti-aliasing g.SmoothingMode = SmoothingMode.AntiAlias; g.PixelOffsetMode = PixelOffsetMode.HighQuality;
CreatePaddle1Region(); CreatePaddle2Region(); CreatePuckPath();
// puck brushes Brush puckBr = new SolidBrush(Color.Red); g.FillPath(puckBr, puckPth); puckBr.Dispose();
// paddle brushes Brush paddleBr = new SolidBrush(Color.Black); g.FillRegion(paddleBr, rgnPaddle1); g.FillRegion(paddleBr, rgnPaddle2); paddleBr.Dispose(); }
Many thanks in advance.
Brian
Cheers for that fellas!
Never even realised it after staring at that block of code for an half an
hour!!
Thanks again!
Brian
Cheers for that fellas!
Never even realised it after staring at that block of code for an half an
hour!!
Thanks again!
Brian This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Charles Law |
last post by:
If I draw a rectangle, 6 inches by 2 inches, on a user control with a
PageUnit of Inches, I get a rectangle of 7 by 2.2 inches.
Is this what people would expect? I would have hoped that it was at...
|
by: Jacek Jurkowski |
last post by:
I have to add a property to an object that is already
allive. The problem is that I'm creating MainMenu
from a definition file ... enyway , there is a need to add
each menu item some extra...
|
by: pei_world |
last post by:
Hi there,
I have a problem about how to keep my draw graphics stay on my control
unless I delete them.
that means how to resist my graphics. also how to partially remove some
graphics from my...
|
by: craig |
last post by:
Quick question for the experts...
Whenever I set the Image property of a PictureBox on one of my forms to a
PNG graphic file on my hard drive, I get the following runtime error when I
try to run...
|
by: David Sobey |
last post by:
Hi
I'm making a custom component using GDI+, a calendar grid thingy. I paint
the grid and numbers in my overrided OnPaint. However, when i go to paint
other things at other times in other...
|
by: Brian Basquille |
last post by:
Hello all,
Just a quick GDI+ related question for you all. I've three ellipses being
drawn in my game. I'm trying to smoothen the edges of them out using
anti-aliasing. Why is it that my puck...
|
by: |
last post by:
We create VC++ programs that does some GDI drawing functionality.
I discovered GDI+ and this seems to be a big step forward, and appears to be
standard available in Windows XP and Windows Server...
|
by: Marcin Rzeznicki |
last post by:
Hello,
Do you think it is legitimate practice to mix GDI+ and GDI calls (via
Get/ReleaseHDC()) in paint event of a control? I've heard there is
possibility of performance loss while "locking"...
|
by: Chris Dunaway |
last post by:
When working with GDI+, calling the CreateGraphics method to draw on a
control has normally been frowned upon and it is always emphasized to
dispose of pens and brushes and other GDI objects lest...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |