Silverfrost Forums

Welcome to our forums

smooth lines (antialiasing)

14 Feb 2024 4:40 #31111

The Gdi+ api provides antialiasing functions and these can be accessed under Clearwin for graphic regions (%gr). However, these do not appear to extend to windows created by %dw or windows created by the api function createwindow.

Is there an alternative method to achieve smooth lines ?

See example below -

  PROGRAM main
  include <windows.ins>
  INTEGER iw,winio@
  integer ctrl
  integer :: parameter, width = 600, height = 600
  iw=winio@('%ca[smooth lines]&amp;')

c set up the surface to draw onto. Remove [smooth4] to see what anti-aliasing has given you iw=winio@('%gr[smooth8]&', width, height) call draw_line_between@(10,0,12,500,0) iw=winio@(' ') c***using %dw winstead
idc=get_bitmap_dc@(1000,800) i=winio@('%dw %bt[ok]&',idc) call set_smoothing_mode@(5) call MoveToEx(idc,10, 0,iold) call LineTo(idc,12,500 ) i=winio@(' ') END PROGRAM main

14 Feb 2024 4:59 #31112

I don't think there is. What would you want to do that can't be done with %gr?

14 Feb 2024 7:15 #31113

Paul

I would like to use line smoothing with windows created with the api createwindow function because my window procedure looks at the messages, wparam and lparam in more detail than I can achieve with calls to clearwin_string@(call_back_reason).

If I could get hold of these values in the %^gr call back function then I may be able to achieve what I want to do,

To show what I mean here is a small extract from my windows procedure

    case WM_HSCROLL:
       switch (LOWORD (wParam))
          {case SB_THUMBTRACK:
             xPos=HIWORD(wParam);
             break;       
           case SB_LINEUP:  
             if (xPos > 0)xPos--;
             break;  
           case SB_LINEDOWN:  
             if (xPos <100)xPos++;
             break; 
          case SB_PAGELEFT:  
             if (xPos > 0)xPos=0;
             break;  
           case SB_PAGERIGHT:  
             if (xPos <100)xPos=100;
             break;                               
           default:
           break; 
          }
        SetScrollPos(hWnd,SB_HORZ,xPos,TRUE);

// send message to flexplan3d fortran routine pushwinstack((LONG) hWnd,(LONG)message,(LONG)wParam,(LONG) lParam);

15 Feb 2024 7:16 #31114

My first thought is that you could try using winio@ with %mg for WM_HSCROLL but there are other possibilities.

Some controls have direct access to the scroll bars. For example, %gr has the options [hscroll] and [vscroll] (see item 441 in cwplus.enh).

%dw uses a handle to a device context (HDC). For GDI+ you would need to call GdiplusStartup and then CreateFromHDC in order to create a GpGraphics pointer from the HDC. This could then be used in calls to the GDI+ primitives that draw lines etc.. In short, at lot of work.

Please login to reply.