Jump to content

Recommended Posts

Posted (edited)

Just developing and testing a parts in a current project.

Needed to draw some dots in a image for previewing/debugging. But there seems to be no direct drawdot function.

Drawing with _GDIPlus_GraphicsDrawLine($hGraphic, $i1, $i2, $i1+1, $i2+1, $hPen) works.

But thats one dot to much. And with ", $i1+0, $i2+0," I get on dot to less. Or no dots at all.

Any know alternative's for drawing dots with GDIPlus UDF's ?

- like to know for general testing purposes. (as final code in this case will probably just dump the used data as raw image data.)

- could be something local. if I recall correctly.

---[e:1]---

Used(stripped-down) code.

#include <WinAPI.au3>
#include <GDIPlus.au3>
_CreateImage('ignored', 'imageout.png', 100, 100)
Exit
Func _CreateImage($aMap_Date, $filename, $iW = 32, $iH = 32, $iColor = 0xFFFF00FF)
    #forceref $aMap_Date

    ;; setup
    Local $hBMP = _WinAPI_CreateBitmap($iW, $iH, 1, 32)
    _GDIPlus_Startup()
    Local $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
    Local $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)
    _GDIPlus_GraphicsClear($hGraphic, $iColor)
    Local $hPen = _GDIPlus_PenCreate()

    ;; draw
    Local $iTmp = 1
    For $i1 = 0 To 20 Step 5 ;; $iW - 1
    For $i2 = 0 To 20 Step 5;; $iH - 1
        _GDIPlus_GraphicsDrawLine($hGraphic, $i1, $i2, $i1 + $iTmp, $i2 + $iTmp, $hPen)
    Next
    Next

    ;; save to image
    _GDIPlus_ImageSaveToFile($hImage1, $filename)

    ;; cleanup
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_GraphicsDispose($hGraphic)
    _WinAPI_DeleteObject($hBMP)
    _GDIPlus_Shutdown()
EndFunc

Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

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
×
×
  • Create New...