Search the Community
Showing results for tags 'text transparent png'.
-
Ciao, I tried to write a text on a transparent png file, but I write text but without background. This is my script: #include <GDIPlus.au3> _GDIPlus_Startup() Global $circle_base = "circle.png" for $sString = 1 to 90 $hBrushNumber = _GDIPlus_BrushCreateSolid(0xFF014990) $hImagetemp = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $circle_base) $iPenWidth = 0 $hPenNumber = _GDIPlus_PenCreate(0xFF014990, $iPenWidth) $hAttribute_Alpha = _GDIPlus_ImageAttributesCreate() $tColorMatrix = _GDIPlus_ColorMatrixCreateTranslate(0, 0, 0, 0) ;0 = opaque, -1 = transparent _GDIPlus_ImageAttributesSetColorMatrix($hAttribute_Alpha, 0, True, DllStructGetPtr($tColorMatrix)) $g_aDim = _GDIPlus_ImageGetDimension($hImagetemp) $g_hImage2 = _GDIPlus_BitmapCreateFromScan0($g_aDim[0], $g_aDim[1]) $g_hGfx = _GDIPlus_ImageGetGraphicsContext($g_hImage2) $hFamily = _GDIPlus_FontFamilyCreate("Uni Sans Heavy CAPS") ;Create font family object $hPath = _GDIPlus_PathCreate() ;Create new path object $tLayout = _GDIPlus_RectFCreate(0,0) ;Create string bounding rectangle X=0, Y=0 _GDIPlus_GraphicsSetSmoothingMode($g_hGfx, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing) _GDIPlus_PathAddString($hPath, $sString, $tLayout, $hFamily, 0, 63, 0) ;Add the outline of the string to the path $aBounds = _GDIPlus_PathGetWorldBounds($hPath) ;Get bounding rectangle of the path X-Y-Width-Height $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($hMatrix,(($g_aDim[0] - $aBounds[2])/2)-$aBounds[0], (($g_aDim[1] - $aBounds[3])/2)-$aBounds[1]) ;translate the matrix _GDIPlus_PathTransform($hPath, $hMatrix) ;apply the above transofrmation _GDIPlus_GraphicsDrawPath($g_hGfx, $hPath, $hPenNumber) ;Draw path to graphics handle _GDIPlus_GraphicsFillPath($g_hGfx, $hPath, $hBrushNumber) ;Fill path with solid color _GDIPlus_ImageSaveToFile($g_hImage2, @ScriptDir & "\numbers\"&$sString&".PNG") Next _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_BrushDispose($hBrushNumber) _GDIPlus_GraphicsDispose($g_hImage2) _GDIPlus_Shutdown() Thankyou Marco