changeset 1682:ea749fb90f7e

Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect(). Enable antialiasing for rectangles on Windows.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 29 Apr 2012 19:46:30 +0000
parents e02101d1b8ba
children 19c34a1c1489
files win/dw.c
diffstat 1 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/win/dw.c	Sat Apr 28 20:42:49 2012 +0000
+++ b/win/dw.c	Sun Apr 29 19:46:30 2012 +0000
@@ -9765,6 +9765,12 @@
  */
 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y)
 {
+#ifdef GDIPLUS
+   /* There doesn't seem to be an equivalent to SetPixel in GDI+ ... 
+    * so instead we call dw_draw_rect() with 1 for width and height.
+    */
+   dw_draw_rect(handle, pixmap, DW_DRAW_FILL | DW_DRAW_NOAA, x, y, 1, 1);
+#else   
    HDC hdcPaint;
 
    if(handle)
@@ -9777,6 +9783,7 @@
    SetPixel(hdcPaint, x, y, (COLORREF)TlsGetValue(_foreground));
    if(!pixmap)
       ReleaseDC(handle, hdcPaint);
+#endif      
 }
 
 /* Draw a line on a window (preferably a render window).
@@ -9955,7 +9962,7 @@
  */
 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height)
 {
- #ifdef GDIPLUS
+#ifdef GDIPLUS
    GpGraphics *graphics = NULL;
    
    if(handle)
@@ -9965,6 +9972,10 @@
    else
       return;
    
+   /* Enable antialiasing if the DW_DRAW_NOAA flag isn't set */
+   if(!(flags & DW_DRAW_NOAA))
+     GdipSetSmoothingMode(graphics, SmoothingModeAntiAlias);
+     
    if(flags & DW_DRAW_FILL)
    {
       GpBrush *brush = TlsGetValue(_gpBrush);
@@ -10107,6 +10118,7 @@
    ColorInfo *cinfo = NULL;
    COLORREF background;
    TCHAR *wtext = UTF8toWide(text);
+   POINT pt;
 
    if(handle)
       hdc = GetDC(handle);
@@ -10139,7 +10151,12 @@
       SetBkMode(hdc, OPAQUE);
       SetBkColor(hdc, background);
    }
-   TextOut(hdc, x, y, wtext, (int)_tcslen(wtext));
+   pt.x = x;
+   pt.y = y;
+#ifdef GDIPLUS1
+   LPtoDP(hdc, &pt, 1);
+#endif
+   TextOut(hdc, pt.x, pt.y, wtext, (int)_tcslen(wtext));
    if(oldFont)
       SelectObject(hdc, oldFont);
    if(mustdelete)