comparison win/dw.c @ 1632:fdf874f25076

Fixed full arcs with GDI+ and disabled antialiased rendering for rectangles. Code for rectangles is still present, #ifdefed out... but other platforms do not seem to currently antialias rectangles, so disabling for now.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 28 Mar 2012 19:17:08 +0000
parents 0e6c2aeed041
children c441c85baa57
comparison
equal deleted inserted replaced
1631:0e6c2aeed041 1632:fdf874f25076
9862 * width: Width of rectangle. 9862 * width: Width of rectangle.
9863 * height: Height of rectangle. 9863 * height: Height of rectangle.
9864 */ 9864 */
9865 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height) 9865 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height)
9866 { 9866 {
9867 #ifdef GDIPLUS 9867 #ifdef GDIPLUS1
9868 if(!(flags & DW_DRAW_NOAA)) 9868 if(!(flags & DW_DRAW_NOAA))
9869 { 9869 {
9870 GpGraphics *graphics = NULL; 9870 GpGraphics *graphics = NULL;
9871 9871
9872 if(handle) 9872 if(handle)
9927 * x2: X coordinate of second segment of arc. 9927 * x2: X coordinate of second segment of arc.
9928 * y2: Y coordinate of second segment of arc. 9928 * y2: Y coordinate of second segment of arc.
9929 */ 9929 */
9930 void API dw_draw_arc(HWND handle, HPIXMAP pixmap, int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2) 9930 void API dw_draw_arc(HWND handle, HPIXMAP pixmap, int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2)
9931 { 9931 {
9932 double dx = xorigin - x1;
9933 double dy = yorigin - y1;
9934 double r = sqrt(dx*dx + dy*dy);
9935 int ri = (int)r;
9936
9937 #ifdef GDIPLUS 9932 #ifdef GDIPLUS
9938 if(!(flags & DW_DRAW_NOAA)) 9933 if(!(flags & DW_DRAW_NOAA))
9939 { 9934 {
9940 GpGraphics *graphics = NULL; 9935 GpGraphics *graphics = NULL;
9941 GpPen *pen = TlsGetValue(_gpPen); 9936 GpPen *pen = TlsGetValue(_gpPen);
9952 { 9947 {
9953 if(flags & DW_DRAW_FILL) 9948 if(flags & DW_DRAW_FILL)
9954 { 9949 {
9955 GpBrush *brush = TlsGetValue(_gpBrush); 9950 GpBrush *brush = TlsGetValue(_gpBrush);
9956 9951
9957 GdipFillEllipseI(graphics, brush, xorigin-ri, yorigin-ri, xorigin+ri, yorigin+ri); 9952 GdipFillEllipseI(graphics, brush, x1 < x2 ? x1 : x2, y1 < y2 ? y1 : y2, abs(x1-x2), abs(y1-y2));
9958 } 9953 }
9959 else 9954 else
9960 GdipDrawEllipseI(graphics, pen, xorigin-ri, yorigin-ri, xorigin+ri, yorigin+ri); 9955 GdipDrawEllipseI(graphics, pen, x1 < x2 ? x1 : x2, y1 < y2 ? y1 : y2, abs(x1-x2), abs(y1-y2));
9961 } 9956 }
9962 else 9957 else
9963 { 9958 {
9964 double a1 = atan2((y1-yorigin), (x1-xorigin)); 9959 double a1 = atan2((y1-yorigin), (x1-xorigin));
9965 double a2 = atan2((y2-yorigin), (x2-xorigin)); 9960 double a2 = atan2((y2-yorigin), (x2-xorigin));
9966 9961
9967 GdipDrawArcI(graphics, pen, xorigin-ri, yorigin-ri, xorigin+ri, yorigin+ri, (REAL)a1, (REAL)a2); 9962 GdipDrawArcI(graphics, pen, x1 < x2 ? x1 : x2, y1 < y2 ? y1 : y2, abs(x1-x2), abs(y1-y2), (REAL)a1, (REAL)a2);
9968 } 9963 }
9969 GdipDeleteGraphics(graphics); 9964 GdipDeleteGraphics(graphics);
9970 } 9965 }
9971 else 9966 else
9972 #endif 9967 #endif
9973 { 9968 {
9974 HDC hdcPaint; 9969 HDC hdcPaint;
9975 HBRUSH oldBrush; 9970 HBRUSH oldBrush;
9976 HPEN oldPen; 9971 HPEN oldPen;
9977 9972 double dx = xorigin - x1;
9973 double dy = yorigin - y1;
9974 double r = sqrt(dx*dx + dy*dy);
9975 int ri = (int)r;
9976
9978 if(handle) 9977 if(handle)
9979 hdcPaint = GetDC(handle); 9978 hdcPaint = GetDC(handle);
9980 else if(pixmap) 9979 else if(pixmap)
9981 hdcPaint = pixmap->hdc; 9980 hdcPaint = pixmap->hdc;
9982 else 9981 else