Click here to Skip to main content
15,885,182 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
hello everybody
When the graphics.drawLine (pen (x1, y1, x2, y2);
X1, y1 values or x2, y2 values greater than 8388608, draw inverse line, how to solve?

What I have tried:

int y = 8388607;
gfx.DrawLine(new Pen(Color.Red, 1), 100, 100, 100, y);
y = 8388608;
gfx.DrawLine(new Pen(Color.Blue, 1), 110, 100, 110, y);
Posted
Updated 13-Sep-18 23:03pm
Comments
Patrice T 13-Sep-18 21:05pm    
Why don't you ask the one that make the graphic library ?
JackX86 13-Sep-18 21:19pm    
Friends, build graphics library how to break through the limit?
Patrice T 13-Sep-18 21:22pm    
Are you asking us for a magic spell about a library we have no idea about ?
Peter_in_2780 13-Sep-18 22:26pm    
https://docs.microsoft.com/en-us/dotnet/framework/winforms/advanced/graphics-and-drawing-in-windows-forms
dan!sh 14-Sep-18 1:48am    
You can check the values of coordinates before calling DrawLine. If any one of them is > 8388607, swap x and y values of each coordinate.

1 solution

Simple: the coordinate system GDI uses is 24 bit: and 8288607 in hex is 7FFFFF - one greater than that becomes a negative number as bit 23 is then set.

No, you can't do anything about that, other than stop trying to draw absurdly large coordinates! There are restrictions on how large a bitmap can be anyway: What is the maximum resolution of C# .NET Bitmap? - Stack Overflow[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900