Jump to content

GDI+ draw text in circle


Recommended Posts

Hello world, I looked around the form to draw a text in a circle around a point. I found this, but it's a bit too complex

My question: It's been 2-3 years since this was posted, has anyone done this in a simpler way? I need to draw it in a circle, not an ellipse, and using a regular $hPen returned from _GDIPlus_PenCreate(). this SHOULD mean you can do it with simpler code, but I could not find any other examples. Is there a simpler way to do this?

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

I assume you don't mean something like #12 Rotating Letters from rather this: http://t1.gstatic.com/images?q=tbn:ANd9GcRSO0bkAFbMoX_MGz9s6yIoLK9oVy6VCXIFfpC-FMg6RqWkxtQy or?

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

@Richard Robertson - Circle makes it simpler, because you only need to specify x|y|radius instead of x|y|w|h

@UEZ - Yes, http://t1.gstatic.com/images?q=tbn:ANd9GcRSO0bkAFbMoX_MGz9s6yIoLK9oVy6VCXIFfpC-FMg6RqWkxtQy is exactly what I need. what is the simplest way to accomplish this?

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

@Richard Robertson - I know this. You could easily calculate it from that, but even if the code provided was for elipse, I would change the perams and add the calculations to make it circle only just for simplicity.

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

Well, it is a fast hack and beta!

#include <Array.au3>
#include <GDIPlus.au3>
Opt("GUIOnEventMode", 1)

_GDIPlus_Startup ()

$iW = 800
$iH = 600

$hgui = GUICreate("GDI+ Rotated Letters by UEZ 2011", $iW, $iH)
GUISetBkColor(0x000020, $hgui)
GUISetState()

$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphic)
$hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)

$sText = "Rotated Letters by UEZ 2011 Beta"
$sLen = StringLen($sText)
$delta_a = Round(360 / $sLen)
$letter_w = 100
$letter_h = 100
$font = "Impact"
$fontsize = 50
$radius = 250
Const $deg = ACos(-1) / 180

Dim $aTable[$sLen][12]

For $i = 0 To $sLen - 1 ;generate table, rotate letters and
    $aTable[$i][0] = StringMid($sText, $i + 1, 1) ;get next letter
    $aTable[$i][1] = _GDIPlus_BitmapCreateFromGraphics($letter_w, $letter_h, $hGraphic) ;create bitmap
    $aTable[$i][2] = _GDIPlus_ImageGetGraphicsContext($aTable[$i][1]) ;create context of bitmap to draw to bitmap
    $aTable[$i][3] = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
    $aTable[$i][4] = _GDIPlus_StringFormatCreate() ;$hFormat
    $aTable[$i][5] = _GDIPlus_FontFamilyCreate($font) ;$hFamily
    $aTable[$i][6] = _GDIPlus_FontCreate($aTable[$i][5], $fontsize) ;$hFont
    $aTable[$i][7] = _GDIPlus_RectFCreate(0, 0, 0, 0) ;$tLayout
    $aTable[$i][8] = _GDIPlus_GraphicsMeasureString ($hGraphic, $aTable[$i][0], $aTable[$i][6], $aTable[$i][7], $aTable[$i][4])
    $aTable[$i][9] = _GDIPlus_MatrixCreate() ;create a matrix for each letter
    $aTable[$i][10] = $i * $delta_a ;calculate angle of letter
    $aTable[$i][11] = $radius ;radius
    _GDIPlus_GraphicsClear($aTable[$i][2], 0x00000000)
    _GDIPlus_GraphicsSetSmoothingMode($aTable[$i][2], 2)

    $a = $aTable[$i][8] ;get pointer from array in array
    $lW = DllStructGetData($a[0], "width")
    $lH = DllStructGetData($a[0], "height")
    DllStructSetData($a[0], "x", $letter_w / 2 - $lW / 2)
    DllStructSetData($a[0], "y", $letter_h / 2 - $lH / 2)

    _GDIPlus_MatrixTranslate($aTable[$i][9], $letter_w / 2, $letter_h / 2)
    _GDIPlus_MatrixRotate($aTable[$i][9], -27 + $aTable[$i][10], False)
    _GDIPlus_MatrixTranslate($aTable[$i][9], -$letter_w / 2, -$letter_h / 2)
    _GDIPlus_GraphicsSetTransform($aTable[$i][2], $aTable[$i][9])

    _GDIPlus_GraphicsDrawStringEx($aTable[$i][2], $aTable[$i][0], $aTable[$i][6], $a[0] , $aTable[$i][4],  $aTable[$i][3])

    $x = $iW / 2 - $letter_w / 2 + Cos(-90 + $aTable[$i][10] * $deg) * $aTable[$i][11]
    $y = $iH / 2 - $letter_h / 2 + Sin(-90 + $aTable[$i][10] * $deg) * $aTable[$i][11]
    _GDIPlus_GraphicsDrawImage($hBackbuffer, $aTable[$i][1], $x , $y)
Next

GUISetOnEvent(-3, "_Exit")

_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH)

While Sleep(1000)
WEnd

Func _Exit()
    For $i = 0 To $sLen - 1
        _GDIPlus_BitmapDispose($aTable[$i][1])
        _GDIPlus_GraphicsDispose($aTable[$i][2])
        _GDIPlus_BrushDispose($aTable[$i][3])
        _GDIPlus_StringFormatDispose($aTable[$i][4])
        _GDIPlus_FontFamilyDispose($aTable[$i][5])
        _GDIPlus_FontDispose($aTable[$i][6])
        _GDIPlus_MatrixDispose($aTable[$i][9])
    Next
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
    Exit
EndFunc

I tried to keep code as simple as possible!

To do? E.g. real time rotation, color of letters, etc.

Have fun,

UEZ

Edit: fixed a bug with string measure array assignment

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

@UEZ thanks, Ima try to work around this. It's quite a bit shorter then the other script.

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

Here with moving of the letters in circle:

;coded by UEZ 2011 build 2011-04-05
#include <Array.au3>
#include <GDIPlus.au3>
Opt("GUIOnEventMode", 1)

_GDIPlus_Startup ()

Const $iW = 600
Const $iW2 = $iW / 2
Const $iH = 600
Const $iH2 = $iH / 2


$hgui = GUICreate("GDI+ Rotated Letters by UEZ 2011 Beta", $iW, $iH)
GUISetBkColor(0x404040, $hgui)
GUISetState()

$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphic)
$hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
;~ _GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)

$sText = " Rotated Letters by UEZ 2011 Beta #"
Const $sLen = StringLen($sText)
Const $delta_a = Floor(360 / $sLen)
Const $letter_w = 100
Const $letter_w2 = $letter_w / 2
Const $letter_h = 100
Const $letter_h2 = $letter_h / 2
Const $center_x = $iW2 - $letter_w2
Const $center_y = $iH2 - $letter_h2

Const $font = "Impact"
Const $fontsize = $sLen * 1.75
Const $radius = 250
Const $deg = ACos(-1) / 180

Dim $aTable[$sLen][12]
$j = $sLen / 2
For $i = 0 To $sLen - 1 ;generate table
    $aTable[$i][0] = StringMid($sText, $i + 1, 1) ;get next letter
    $aTable[$i][1] = _GDIPlus_BitmapCreateFromGraphics($letter_w, $letter_h, $hGraphic) ;create bitmap
    $aTable[$i][2] = _GDIPlus_ImageGetGraphicsContext($aTable[$i][1]) ;create context of bitmap to draw to bitmap
    $r = 0xFF - Sin($j / 10) * 20
    $g = 0xFF - Sin($j / 10) * 100
    $b = 0xFF - Sin($j / 10) * 220
    $j -= 0.5
    $aTable[$i][3] = _GDIPlus_BrushCreateSolid("0xFF" & Hex($r, 2) & Hex($g, 2) &Hex($b, 2))
    $aTable[$i][4] = _GDIPlus_StringFormatCreate() ;$hFormat
    $aTable[$i][5] = _GDIPlus_FontFamilyCreate($font) ;$hFamily
    $aTable[$i][6] = _GDIPlus_FontCreate($aTable[$i][5], $fontsize) ;$hFont
    $aTable[$i][7] = _GDIPlus_RectFCreate(0, 0, 0, 0) ;$tLayout
    $aTable[$i][8] = _GDIPlus_GraphicsMeasureString($hGraphic, $aTable[$i][0], $aTable[$i][6], $aTable[$i][7], $aTable[$i][4])
    $aTable[$i][9] = _GDIPlus_MatrixCreate() ;create a matrix for each letter
    $aTable[$i][10] = $i * $delta_a ;calculate angle of letter
    $aTable[$i][11] = $radius ;radius
    _GDIPlus_GraphicsSetSmoothingMode($aTable[$i][2], 2)

    _GDIPlus_GraphicsClear($aTable[$i][2], 0x00000000)
    ;calculated possition of letter to place it in the middle of the graphic
    $a = $aTable[$i][8]
    $lW = DllStructGetData($a[0], "width")
    $lH = DllStructGetData($a[0], "height")
    DllStructSetData($a[0], "x", $letter_w2 - $lW / 2)
    DllStructSetData($a[0], "y", $letter_h2 - $lH / 2)

    ;rotate letter
    _GDIPlus_MatrixTranslate($aTable[$i][9], $letter_w2, $letter_h2)
    _GDIPlus_MatrixRotate($aTable[$i][9], -27 + $aTable[$i][10], False)
    _GDIPlus_MatrixTranslate($aTable[$i][9], -$letter_w2, -$letter_h2)
    _GDIPlus_GraphicsSetTransform($aTable[$i][2], $aTable[$i][9])

    ;print letter to graphic
    _GDIPlus_GraphicsDrawStringEx($aTable[$i][2], $aTable[$i][0], $aTable[$i][6], $a[0] , $aTable[$i][4],  $aTable[$i][3])

    ;copy letter to main screen in a circle
    $x = $center_x + Cos(-90 + $aTable[$i][10] * $deg) * $aTable[$i][11]
    $y = $center_y + Sin(-90 + $aTable[$i][10] * $deg) * $aTable[$i][11]
    _GDIPlus_GraphicsDrawImage($hBackbuffer, $aTable[$i][1], $x , $y)
Next

GUISetOnEvent(-3, "_Exit")

_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH)

While Sleep(20)
    Rotation1()
WEnd

Func Rotation1()
    _GDIPlus_GraphicsClear($hBackbuffer, 0x70202040)
    For $i = 0 To $sLen - 1
        _GDIPlus_GraphicsClear($aTable[$i][2], 0x00000000)
        $aTable[$i][10] += 0.5
        $a = $aTable[$i][8]
        _GDIPlus_MatrixTranslate($aTable[$i][9], $letter_w2, $letter_h2)
        _GDIPlus_MatrixRotate($aTable[$i][9], 0.5, False)
        _GDIPlus_MatrixTranslate($aTable[$i][9], -$letter_w2, -$letter_h2)
        _GDIPlus_GraphicsSetTransform($aTable[$i][2], $aTable[$i][9])

        _GDIPlus_GraphicsDrawStringEx($aTable[$i][2], $aTable[$i][0], $aTable[$i][6], $a[0] , $aTable[$i][4],  $aTable[$i][3])

        $x = $center_x + Cos(-90 + $aTable[$i][10] * $deg) * $aTable[$i][11]
        $y = $center_y + Sin(-90 + $aTable[$i][10] * $deg) * $aTable[$i][11]
        _GDIPlus_GraphicsDrawImage($hBackbuffer, $aTable[$i][1], $x , $y)
    Next
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH)
EndFunc

Func _Exit()
    For $i = 0 To $sLen - 1
        _GDIPlus_BitmapDispose($aTable[$i][1])
        _GDIPlus_GraphicsDispose($aTable[$i][2])
        _GDIPlus_BrushDispose($aTable[$i][3])
        _GDIPlus_StringFormatDispose($aTable[$i][4])
        _GDIPlus_FontFamilyDispose($aTable[$i][5])
        _GDIPlus_FontDispose($aTable[$i][6])
        _GDIPlus_MatrixDispose($aTable[$i][9])
    Next
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
    Exit
EndFunc

The rotation of the letters are currently still too "fitfully". :)

I hope I can fix it...

Br,

UEZ

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

Lol it looks like you rotate each letter by itself, couldn't you draw all the letters to a single bitmap and just rotate the bitmap around it's center?

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

Lol it looks like you rotate each letter by itself, couldn't you draw all the letters to a single bitmap and just rotate the bitmap around it's center?

Of course I can but then you don't have the flexibilty to do some more effects on each letter! :)

You can print the rotated letters to the bitmap and rotate only the visible screen...

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

You've lost me. I've been trying to turn the first script into a function (I need to call it 3 times with different prams at the beginning) but I failed epicly. I don't need to ever rotate the letters one by one, I need only to draw them to a bitmap which I can rotate. Help?

@UEZ

If you plan to make a more complex version of this, the thread I linked to in post 1 used this to get the width of each character. This code may be useful to calculate letter angles in instances where you have multiple "skinny" letters, like llllll or iiiiiii. However, this functionality is not useful for my script.

For $n = 1 To $aChar[0]
        ;ConsoleWrite($n & "  " & $aChar[$n] & "  Width = ")
        $hFormat = _GDIPlus_StringFormatCreate(0)
        $hFamily = _GDIPlus_FontFamilyCreate($nFontName)
        $hFont = _GDIPlus_FontCreate($hFamily, $nFontSize, 3, 3)
        $tLayout = _GDIPlus_RectFCreate(50, 50, 0, 0)
        $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $aChar[$n], $hFont, $tLayout, $hFormat)
        $aCharAll[$n][1] = Ceiling(DllStructGetData($aInfo[0], "Width"))
        $aCharAll[$n][2] = Ceiling(DllStructGetData($aInfo[0], "Height"))
        If $aCharAll[$n][1] > $iMaxRectWidth Then $iMaxRectWidth = $aCharAll[$n][1]
        ;ConsoleWrite($aCharAll[$n][1 ]& " Height =  " & $aCharAll[$n][2] & @CRLF)
    Next
Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

corgano, what about this version?

;coded by UEZ 2011 build 2011-04-06
;~ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0
#AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_Obfuscated.au3"
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_UPX_Parameters=--brute --crp-ms=999999 --all-methods --all-filters

#include <Array.au3>
#include <GDIPlus.au3>
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)

_GDIPlus_Startup()

Global Const $iW = 600
Global Const $iH = 600
Global Const $iW2 = $iW / 2
Global Const $iH2 = $iH / 2

Global Const $hgui = GUICreate("GDI+ Rotated Letters by UEZ 2011 Beta", $iW, $iH)
GUISetBkColor(0x202040, $hgui)
WinSetTrans($hgui, "", 0xFF)
GUISetState()

Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hgui)
Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphic)
Global $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)
Global $ps = 4
Global $hPen = _GDIPlus_PenCreate(0xFFFFA000, $ps)
Global $radius = 250
Global $sText = " Rotated Letters by UEZ 2011 Beta #"
Global $hBMP = CreateRotatedLetters($sText, $iW, $iH)

Global $hMatrix = _GDIPlus_MatrixCreate()
_GDIPlus_GraphicsDrawImageRect($hBackbuffer, $hBMP, 0, 0, $iW, $iH)

GUISetOnEvent(-3, "_Exit")
Global $i = 0
While Sleep(10)
    $i -= 0.01
    _GDIPlus_GraphicsClear($hBackbuffer, 0x80202020)
    _GDIPlus_GraphicsDrawImageRect($hBackbuffer, $hBMP, 0, 0, $iW, $iH)
    _GDIPlus_GraphicsDrawEllipse($hBackbuffer, $ps - 2, $ps - 2, $iW - $ps - 2, $iH - $ps - 2, $hPen)
    _GDIPlus_GraphicsDrawEllipse($hBackbuffer, 95, 95, $iW - 2 * 95, $iH - 2 * 95, $hPen)
    _GDIPlus_MatrixTranslate($hMatrix, $iW2, $iH2)
    _GDIPlus_MatrixRotate($hMatrix, Sin($i), False)
    _GDIPlus_MatrixTranslate($hMatrix, -$iW2, -$iH2)
    _GDIPlus_GraphicsSetTransform($hBackbuffer, $hMatrix)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH)
WEnd

Func CreateRotatedLetters($sText, $iW, $iH, $fontsize = 60, $radius = 250, $letter_w = 100, $letter_h = 100, $font = "Impact", $rv = 20, $gv = 100, $bv = 240, $start_angle = 0)
    Local Const $iW2 = $iW / 2
    Local Const $iH2 = $iH / 2
    Local Const $sLen = StringLen($sText)
    Local $j = $sLen / 2
    Local Const $delta_a = Floor(360 / $sLen)
    Local Const $letter_w2 = $letter_w / 2
    Local Const $letter_h2 = $letter_h / 2
    Local Const $center_x = $iW2 - $letter_w2
    Local Const $center_y = $iH2 - $letter_h2
    Local Const $deg = ACos(-1) / 180

    Local $aTable[$sLen][12]
    Local $i, $r, $g, $b, $a, $lW, $lH, $x, $y
    Local $hImage = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hImage)
    For $i = 0 To $sLen - 1 ;generate table
        $aTable[$i][0] = StringMid($sText, $i + 1, 1) ;get next letter
        $aTable[$i][1] = _GDIPlus_BitmapCreateFromScan0($letter_w, $letter_h) ;create bitmap
        $aTable[$i][2] = _GDIPlus_ImageGetGraphicsContext($aTable[$i][1]) ;create context of bitmap to draw to bitmap
        $r = 0xFF - Sin($j / 10) * $rv
        $g = 0xFF - Sin($j / 10) * $gv
        $b = 0xFF - Sin($j / 10) * $bv
        $j -= 0.5
        $aTable[$i][3] = _GDIPlus_BrushCreateSolid("0xE0" & Hex($r, 2) & Hex($g, 2) & Hex($b, 2))
        $aTable[$i][4] = _GDIPlus_StringFormatCreate() ;$hFormat
        $aTable[$i][5] = _GDIPlus_FontFamilyCreate($font) ;$hFamily
        $aTable[$i][6] = _GDIPlus_FontCreate($aTable[$i][5], $fontsize) ;$hFont
        $aTable[$i][7] = _GDIPlus_RectFCreate(0, 0, 0, 0) ;$tLayout
        $aTable[$i][8] = _GDIPlus_GraphicsMeasureString($hGraphic, $aTable[$i][0], $aTable[$i][6], $aTable[$i][7], $aTable[$i][4])
        $aTable[$i][9] = _GDIPlus_MatrixCreate() ;create a matrix for each letter
        $aTable[$i][10] = $i * $delta_a + $start_angle ;calculate angle of letter
        $aTable[$i][11] = $radius ;radius
        _GDIPlus_GraphicsSetSmoothingMode($aTable[$i][2], 2)

        _GDIPlus_GraphicsClear($aTable[$i][2], 0x00000000)
        ;calculated possition of letter to place it in the middle of the graphic
        $a = $aTable[$i][8]
        $lW = DllStructGetData($a[0], "width")
        $lH = DllStructGetData($a[0], "height")
        DllStructSetData($a[0], "x", $letter_w2 - $lW / 2)
        DllStructSetData($a[0], "y", $letter_h2 - $lH / 2)

        ;rotate letter
        _GDIPlus_MatrixTranslate($aTable[$i][9], $letter_w2, $letter_h2)
        _GDIPlus_MatrixRotate($aTable[$i][9], -27 + $aTable[$i][10], False)
        _GDIPlus_MatrixTranslate($aTable[$i][9], -$letter_w2, -$letter_h2)
        _GDIPlus_GraphicsSetTransform($aTable[$i][2], $aTable[$i][9])

        ;print letter to bitmap
        _GDIPlus_GraphicsDrawStringEx($aTable[$i][2], $aTable[$i][0], $aTable[$i][6], $a[0], $aTable[$i][4], $aTable[$i][3])

        ;copy letter to main screen in a circle
        $x = $center_x + Cos(-90 + $aTable[$i][10] * $deg) * $aTable[$i][11]
        $y = $center_y + Sin(-90 + $aTable[$i][10] * $deg) * $aTable[$i][11]
        _GDIPlus_GraphicsDrawImage($hContext, $aTable[$i][1], $x, $y)
    Next

    For $i = 0 To $sLen - 1
        _GDIPlus_BitmapDispose($aTable[$i][1])
        _GDIPlus_GraphicsDispose($aTable[$i][2])
        _GDIPlus_BrushDispose($aTable[$i][3])
        _GDIPlus_StringFormatDispose($aTable[$i][4])
        _GDIPlus_FontFamilyDispose($aTable[$i][5])
        _GDIPlus_FontDispose($aTable[$i][6])
        _GDIPlus_MatrixDispose($aTable[$i][9])
    Next
    _GDIPlus_GraphicsDispose($hContext)
    Return $hImage
EndFunc   ;==>CreateRotatedLetters

Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aResult[6]
EndFunc   ;==>_GDIPlus_BitmapCreateFromScan0

Func _Exit()
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_BitmapDispose($hBMP)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
    GUIDelete($hgui)
    Exit
EndFunc   ;==>_Exit

Btw, does anyone know why _GDIPlus_GraphicsSetSmoothingMode() is not working with with _GDIPlus_GraphicsDrawStringEx() on Vista+ os'?

Br,

UEZ

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

Question, What does _GDIPlus_BitmapCreateFromScan0 do?

Other then that, the code makes sense and I am able to use it. I'll have something to show you in a bit. Thanks UEZ!

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

Creating an empty 32bit bitmap.

From GDIp.au3:

; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_BitmapCreateFromScan0
; Description ...: Creates a Bitmap object based on an array of bytes along with size and format information
; Syntax.........: _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight[, $iStride = 0[, $iPixelFormat = 0x0026200A[, $pScan0 = 0]]])
; Parameters ....: $iWidth      - The bitmap width, in pixels
;                  $iHeight     - The bitmap height, in pixels
;                  $iStride     - Integer that specifies the byte offset between the beginning of one scan line and the next. This
;                  +is usually (but not necessarily) the number of bytes in the pixel format (for example, 2 for 16 bits per pixel)
;                  +multiplied by the width of the bitmap. The value passed to this parameter must be a multiple of four
;                  $iPixelFormat - Specifies the format of the pixel data. Can be one of the following:
;                  |$GDIP_PXF01INDEXED   - 1 bpp, indexed
;                  |$GDIP_PXF04INDEXED   - 4 bpp, indexed
;                  |$GDIP_PXF08INDEXED   - 8 bpp, indexed
;                  |$GDIP_PXF16GRAYSCALE - 16 bpp, grayscale
;                  |$GDIP_PXF16RGB555    - 16 bpp; 5 bits for each RGB
;                  |$GDIP_PXF16RGB565    - 16 bpp; 5 bits red, 6 bits green, and 5 bits blue
;                  |$GDIP_PXF16ARGB1555  - 16 bpp; 1 bit for alpha and 5 bits for each RGB component
;                  |$GDIP_PXF24RGB       - 24 bpp; 8 bits for each RGB
;                  |$GDIP_PXF32RGB       - 32 bpp; 8 bits for each RGB. No alpha.
;                  |$GDIP_PXF32ARGB      - 32 bpp; 8 bits for each RGB and alpha
;                  |$GDIP_PXF32PARGB     - 32 bpp; 8 bits for each RGB and alpha, pre-mulitiplied
;                  $pScan0      - Pointer to an array of bytes that contains the pixel data. The caller is responsible for
;                  +allocating and freeing the block of memory pointed to by this parameter.
; Return values .: Success      - Returns a handle to a new Bitmap object
;                  Failure      - 0 and either:
;                  |@error and @extended are set if DllCall failed
;                  |$GDIP_STATUS contains a non zero value specifying the error code
; Remarks .......: After you are done with the object, call _GDIPlus_ImageDispose to release the object resources
; Related .......: _GDIPlus_ImageDispose
; Link ..........; @@MsdnLink@@ GdipCreateBitmapFromScan0
; Example .......; Yes
; ===============================================================================================================================

Br,

UEZ

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...