comparison win/dw.c @ 1633:c441c85baa57

Fix rendering Arc segments in anti-antialiased mode on Windows.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 28 Mar 2012 23:11:12 +0000
parents fdf874f25076
children cdbf4cc929fc
comparison
equal deleted inserted replaced
1632:fdf874f25076 1633:c441c85baa57
20 #include <stdio.h> 20 #include <stdio.h>
21 #include <process.h> 21 #include <process.h>
22 #include <malloc.h> 22 #include <malloc.h>
23 #include <io.h> 23 #include <io.h>
24 #include <time.h> 24 #include <time.h>
25 #define _USE_MATH_DEFINES
25 #include <math.h> 26 #include <math.h>
26 #include "dw.h" 27 #include "dw.h"
27 #ifdef BUILD_DLL 28 #ifdef BUILD_DLL
28 #include "XBrowseForFolder.h" 29 #include "XBrowseForFolder.h"
29 #endif 30 #endif
9956 } 9957 }
9957 else 9958 else
9958 { 9959 {
9959 double a1 = atan2((y1-yorigin), (x1-xorigin)); 9960 double a1 = atan2((y1-yorigin), (x1-xorigin));
9960 double a2 = atan2((y2-yorigin), (x2-xorigin)); 9961 double a2 = atan2((y2-yorigin), (x2-xorigin));
9962 double dx = xorigin - x1;
9963 double dy = yorigin - y1;
9964 double r = sqrt(dx*dx + dy*dy);
9965 double sweep;
9966 int ri = (int)r;
9961 9967
9962 GdipDrawArcI(graphics, pen, x1 < x2 ? x1 : x2, y1 < y2 ? y1 : y2, abs(x1-x2), abs(y1-y2), (REAL)a1, (REAL)a2); 9968 /* Convert to degrees */
9969 a1 *= (180.0 / M_PI);
9970 a2 *= (180.0 / M_PI);
9971 sweep = fabs(a1 - a2);
9972
9973 GdipDrawArcI(graphics, pen, xorigin-ri, yorigin-ri, ri*2, ri*2, (REAL)a1, (REAL)sweep);
9963 } 9974 }
9964 GdipDeleteGraphics(graphics); 9975 GdipDeleteGraphics(graphics);
9965 } 9976 }
9966 else 9977 else
9967 #endif 9978 #endif
9987 oldBrush = SelectObject( hdcPaint, GetStockObject(HOLLOW_BRUSH) ); 9998 oldBrush = SelectObject( hdcPaint, GetStockObject(HOLLOW_BRUSH) );
9988 oldPen = SelectObject( hdcPaint, TlsGetValue(_hPen) ); 9999 oldPen = SelectObject( hdcPaint, TlsGetValue(_hPen) );
9989 if(flags & DW_DRAW_FULL) 10000 if(flags & DW_DRAW_FULL)
9990 Ellipse(hdcPaint, x1, y1, x2, y2); 10001 Ellipse(hdcPaint, x1, y1, x2, y2);
9991 else 10002 else
9992 Arc(hdcPaint, xorigin-(int)r, yorigin-(int)r, xorigin+(int)r, yorigin+(int)r, x2, y2, x1, y1); 10003 Arc(hdcPaint, xorigin-ri, yorigin-ri, xorigin+ri, yorigin+ri, x2, y2, x1, y1);
9993 SelectObject( hdcPaint, oldBrush ); 10004 SelectObject( hdcPaint, oldBrush );
9994 SelectObject( hdcPaint, oldPen ); 10005 SelectObject( hdcPaint, oldPen );
9995 10006
9996 if(!pixmap) 10007 if(!pixmap)
9997 ReleaseDC(handle, hdcPaint); 10008 ReleaseDC(handle, hdcPaint);