Jump to content

Make the line thinner than 1 in GDI plus


topten
 Share

Recommended Posts

I have a ine drawn with GDI

_GDIPlus_PenSetColor($g_hPen, 0xE5FFFFFF) ;set pen color for inner lines
 _GDIPlus_PenSetWidth($g_hPen, 1) ;set pen size for outer lines
_GDIPlus_GraphicsDrawLine($g_hGfxCtxt, 730,0, 730, 400, $g_hPen)
_WinAPI_BitBlt($g_hDC, 0, 0, $iWidth, $iHeight, $g_hDC_Backbuffer, 0, 0, $SRCCOPY)

I find this line thick, but even if I set the thickness

_GDIPlus_PenSetWidth($g_hPen, 0.1)

nothing changes and the line stays as thick as it was before. Is there any possibility to reduce line thickness?

Link to comment
Share on other sites

Afaik there is no possibility to draw less than 1 pixel dimension. How should this be displayed?

Might be an issue with anti aliasing that the line looks taller than 1 pixel.

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

As mentioned in my previous post anti aliasing (smoothness) is enabled (_GDIPlus_GraphicsSetSmoothingMode).

Disabled it and you will see the difference.

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

You are right, JohnOne

I have smoothing mode switched on

$g_hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $g_hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    ;create a faster buffered graphics frame set for smoother gfx object movements
    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight) ;create an empty bitmap
    $g_hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) ;convert GDI+ bitmap to GDI bitmap
    _GDIPlus_BitmapDispose($hBitmap) ;delete GDI+ bitmap because not needed anymore

    $g_hDC = _WinAPI_GetDC($g_hGUI) ;get device context from GUI
    $g_hDC_Backbuffer = _WinAPI_CreateCompatibleDC($g_hDC) ;creates a memory device context compatible with the specified device
    $g_oDC_Obj = _WinAPI_SelectObject($g_hDC_Backbuffer, $g_hHBITMAP) ;selects an object into the specified device context
 Global   $g_hGfxCtxt = _GDIPlus_GraphicsCreateFromHDC($g_hDC_Backbuffer) ;create a graphics object from a device context (DC)
    _GDIPlus_GraphicsSetSmoothingMode($g_hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;set smoothing mode (8 X 4 box filter)
   _GDIPlus_GraphicsSetPixelOffsetMode($g_hGfxCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)

Does it mean that if I switch off smoothing mode- the static part will become thin, but  the dynamic part will be not so smooth though

Link to comment
Share on other sites

In the help file there is an example which shows both mode -> _GDIPlus_GraphicsSetSmoothingMode.

 

Btw, a horizontal / vertical line looks thinner than a diagonal line at smaller pen width sizes when smoothing (anti aliasing) is activated.

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...