Jump to content

GDIPlus messing up Text


Recommended Posts

Derp, accidently it

Ok, so when I make some text with GDIplus, it attempts to make it look better by adding hue to the right / left sides of letters. example:

Posted Image

The top "this" is the rendered text, the bottom one is the same with the pixels magnified 600%

I do not want it to do this! Please help

#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
_Main()
Func _Main()
Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout
Local $sString = "This is a string", $aInfo
; Create GUI
$hGUI = GUICreate("GDI+", 150, 60)
; Draw a string
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics(150,60,$hGraphic)
$hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
$hBrush = _GDIPlus_BrushCreateSolid(0xFF000000)
$hBrush2 = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFamily, 12, 1)
$tLayout = _GDIPlus_RectFCreate(15, 15, 150, 30)
_GDIPlus_GraphicsFillRect($hContext,0,0,150,60,$hBrush2)
_GDIPlus_GraphicsDrawStringEx($hContext, $sString, $hFont, $tLayout, $hFormat, $hBrush)
_GDIPlus_ImageSaveToFile($hBitmap,"This is an image.png")
ShellExecute("This is an image.png")
; Clean up resources
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_BrushDispose($hBrush2)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
EndFunc ;==>_Main
Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

Please post your code so we can help you ;)

Hi!

My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Link to comment
Share on other sites

The main script is very long and has a good many issues, but I put code relivant to this issue in the first post. Just want to take them on one at a time :P

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

The main script is very long and has a good many issues, but I put code relivant to this issue in the first post. Just want to take them on one at a time :P

Yes you have put the code in the first post but you have deleted what your issue is :P. Because your posted code seems to work good here ;)

Hi!

My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Link to comment
Share on other sites

do me a favor, open the generated image in paint, zoom in. does it look like the above image? Do the letters have the red / blue fading to the sides? Or is it black and white?

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

All seems to be fine here:

Posted Image

Hi!

My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Link to comment
Share on other sites

Is that in paint? I know windows picture viewer blurrs the pixels when you zoom in, but paint doesn't

My issue is that in an attempt to make the text look better on screens is that it gives pixels by letters red or blue hues that look bad when printed

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

Tested with paint and the gimp and all seems fine here.

Hi!

My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Link to comment
Share on other sites

Ok, then it's probably something wrong in the system scope... Checking clear type blarky, can anyone confirm this?

Edit, all text on my computer has a similar effect to it, but cleartype is turned off? Is there any way to overwrite it when GDI makes the text?

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

You have to disable smoothing aka antialiasing. Try this:

#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
Global Enum $TextRenderingHintSystemDefault = 0,  _
            $TextRenderingHintSingleBitPerPixelGridFit, _
            $TextRenderingHintSingleBitPerPixel, _
            $TextRenderingHintAntiAliasGridFit, _
            $TextRenderingHintAntiAlias, _
            $TextRenderingHintClearTypeGridFit
_Main()
Func _Main()
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout
    Local $sString = "This is a string", $aInfo
    ; Create GUI
    $hGUI = GUICreate("GDI+", 150, 60)
    ; Draw a string
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics(150, 60, $hGraphic)
    $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "handle", $hContext, "int", $TextRenderingHintSingleBitPerPixelGridFit)
    _GDIPlus_GraphicsSetSmoothingMode($hContext, 0)
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000)
    $hBrush2 = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 12, 1)
    $tLayout = _GDIPlus_RectFCreate(15, 15, 150, 30)
    _GDIPlus_GraphicsFillRect($hContext, 0, 0, 150, 60, $hBrush2)
    _GDIPlus_GraphicsDrawStringEx($hContext, $sString, $hFont, $tLayout, $hFormat, $hBrush)
    _GDIPlus_ImageSaveToFile($hBitmap, "This is an image.png")
    ShellExecute("This is an image.png")
    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_BrushDispose($hBrush2)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Main

Br,

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

  • 1 year later...

I stumbled upon this thread again, and wondered if it was fixed in that example....

GII2Q3G.pngSince posting this I am on a completely different laptop. Still same issue.

At this point I have no idea what is causing it or if it's fixable.

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

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

×
×
  • Create New...