473,231 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

GraphicsPath.IsVisible(): Unexpected Results

/*
GraphicsPath.IsVisible() gives unexpected results. I fill a
System.Drawing.Drawing2D.GraphicsPath-object with PointF-structures
that define the unit-square (0,0), (1,0), (1,1) and (0,1). Then I
test 3 different PointF-structures to see if they fall inside the unit-
square and the results are clearly wrong:

Point(-0.2, -0.2) falls inside the unit square... WRONG!!!
Point(0.2, 0.2) falls inside the unit square...
Point(0.7, 0.7) falls outside the unit square... WRONG!!!

It seems that the float numbers get rounded to the nearest integer, but
that is not what I want.
*/

//class TestGraphicsPath
class TestGraphicsPath
{
//data member graphicspath
System.Drawing.Drawing2D.GraphicsPath graphicspath=new
System.Drawing.Drawing2D.GraphicsPath();
//constructor
TestGraphicsPath()
{
graphicspath.AddLines
(
new System.Drawing.PointF[]
{
new System.Drawing.PointF(0f,0f),
new System.Drawing.PointF(1f,0f),
new System.Drawing.PointF(1f,1f),
new System.Drawing.PointF(0f,1f),
new System.Drawing.PointF(0f,0f),
}
);
TestPoint(new System.Drawing.PointF(-.2f,-.2f));
TestPoint(new System.Drawing.PointF(.2f,.2f));
TestPoint(new System.Drawing.PointF(.7f,.7f));
}
//TestPoint
void TestPoint(System.Drawing.PointF a)
{
System.Console.Write("Point({0}, {1}) falls ",a.X,a.Y);
System.Console.Write(graphicspath.IsVisible(a)?"in side ":"outside ");
System.Console.WriteLine("the unit square...");
}
//Main
static void Main()
{
new TestGraphicsPath();
}
}

/*
____________________
output:

Point(-0,2, -0,2) falls inside the unit square...
Point(0,2, 0,2) falls inside the unit square...
Point(0,7, 0,7) falls outside the unit square...
*/

Nov 2 '06 #1
2 5376
GraphicsPath objects do indeed convert floats to integers. Oops on the part
of the GDI+ team eh?

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

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.

"Martijn Mulder" <i@mwrote in message
news:45***********************@news.wanadoo.nl...
/*
GraphicsPath.IsVisible() gives unexpected results. I fill a
System.Drawing.Drawing2D.GraphicsPath-object with PointF-structures
that define the unit-square (0,0), (1,0), (1,1) and (0,1). Then I
test 3 different PointF-structures to see if they fall inside the unit-
square and the results are clearly wrong:

Point(-0.2, -0.2) falls inside the unit square... WRONG!!!
Point(0.2, 0.2) falls inside the unit square...
Point(0.7, 0.7) falls outside the unit square... WRONG!!!

It seems that the float numbers get rounded to the nearest integer, but
that is not what I want.
*/

//class TestGraphicsPath
class TestGraphicsPath
{
//data member graphicspath
System.Drawing.Drawing2D.GraphicsPath graphicspath=new
System.Drawing.Drawing2D.GraphicsPath();
//constructor
TestGraphicsPath()
{
graphicspath.AddLines
(
new System.Drawing.PointF[]
{
new System.Drawing.PointF(0f,0f),
new System.Drawing.PointF(1f,0f),
new System.Drawing.PointF(1f,1f),
new System.Drawing.PointF(0f,1f),
new System.Drawing.PointF(0f,0f),
}
);
TestPoint(new System.Drawing.PointF(-.2f,-.2f));
TestPoint(new System.Drawing.PointF(.2f,.2f));
TestPoint(new System.Drawing.PointF(.7f,.7f));
}
//TestPoint
void TestPoint(System.Drawing.PointF a)
{
System.Console.Write("Point({0}, {1}) falls ",a.X,a.Y);
System.Console.Write(graphicspath.IsVisible(a)?"in side ":"outside ");
System.Console.WriteLine("the unit square...");
}
//Main
static void Main()
{
new TestGraphicsPath();
}
}

/*
____________________
output:

Point(-0,2, -0,2) falls inside the unit square...
Point(0,2, 0,2) falls inside the unit square...
Point(0,7, 0,7) falls outside the unit square...
*/

Nov 2 '06 #2
>GraphicsPath.IsVisible() gives unexpected results. I fill a
>System.Drawing.Drawing2D.GraphicsPath-object with PointF-structures
that define the unit-square (0,0), (1,0), (1,1) and (0,1). Then I
test 3 different PointF-structures to see if they fall inside the unit-
square and the results are clearly wrong:

Point(-0.2, -0.2) falls inside the unit square... WRONG!!!
Point(0.2, 0.2) falls inside the unit square...
Point(0.7, 0.7) falls outside the unit square... WRONG!!!

It seems that the float numbers get rounded to the nearest integer, but
that is not what I want.
<SNIP code example>

GraphicsPath objects do indeed convert floats to integers. Oops on the
part of the GDI+ team eh?

Is this sloppy enough to call it a bug?
Nov 3 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Altramagnus | last post by:
I have a complicated Region object, which I need to draw the outline, but not fill How can I convert the Region object to GraphicsPath object? or How can I draw the outline of the Region object?
6
by: Altramagnus | last post by:
I have n number of circles. Some of them might overlap. I need to draw the outline of all circles but not those overlap areas. Initially, I am try to use a Region, because a Region object has a...
1
by: jay | last post by:
I have a bitmap and a graphicspath object. I draw pixels on m_Bitmap and I'm drawing text using m_Graphics GraphicsPath object. However, saving my work with m_Bitmap.Save doesn't save...
7
by: Crirus | last post by:
Hi Is that true that this IsVisible method is incredible slow? Seems that my app is much slower with only this added as a condition to draw something Crirus
1
by: Mike | last post by:
The .NET class libary presents this as an example of GraphicsPath.IsVisible: Public Sub IsVisibleExample(ByVal e As PaintEventArgs) Dim myPath As New GraphicsPath myPath.AddEllipse(0, 0, 100,...
1
by: NosherRees | last post by:
I'm using GraphicsPath to draw text onto a graphics object (PictureBox). My graphics object has been scaled so that the top left corner is 400000, 6000000 and the bottom right corner is 400100,...
3
by: iwasinnihon | last post by:
I have created a form that has a list box that displays information queried from a table. I then have a textbox under the form and three buttons under that(Add, Update, Delete). When the form is...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.