Erstellt ein Bitmap Objekt basierend auf einem Array von Bytes mit den Größen- und Formatinformationen
#include <GDIPlus.au3>
_GDIPlus_BitmapCreateFromScan0 ( $iWidth, $iHeight [, $iPixelFormat = $GDIP_PXF32ARGB [, $iStride = 0 [, $pScan0 = 0]]] )
$iWidth | Die Bitmapbreite in Pixeln. |
$iHeight | Die Bitmaphöhe in Pixeln. |
$iPixelFormat | [optional] Legt das Format der Pixeldaten fest. $GDIP_PXF01INDEXED = 1 bit je pixel, indiziert $GDIP_PXF04INDEXED = 4 bits je pixel, indiziert $GDIP_PXF08INDEXED = 8 bits je pixel, indiziert $GDIP_PXF16GRAYSCALE = 16 bits je pixel, Graustufen $GDIP_PXF16RGB555 = 16 bits je pixel; 5 bits für jede RGB Komponente $GDIP_PXF16RGB565 = 16 bits je pixel; 5 bits für Rot, 6 bits für Grün und 5 bits Blau $GDIP_PXF16ARGB1555 = 16 bits je pixel; 1 bit für alpha und 5 bits für jede RGB Komponente $GDIP_PXF24RGB = 24 bits je pixel; 8 bits für jede RGB Komponente $GDIP_PXF32RGB = 32 bits je pixel; 8 bits für jede RGB Komponente. Keine alpha Komponente. $GDIP_PXF32ARGB = 32 bits je pixel; 8 bits für jede RGB und Alpha Komponente $GDIP_PXF32PARGB = 32 bits je pixel; 8 bits für jede RGB und Alpha Komponente, vor-multipliziert |
$iStride | [optional] Zahl die den Byteoffset zwischen der Start Scanline und der nächsten festlegt |
$pScan0 | [optional] Zeiger auf ein Array von Bytes das die Pixeldaten beinhaltet |
Erfolg: | ein Handle zu einem neuen Bitmap Objekt. |
Fehler: | 0 und setzt das @error Flag auf ungleich null, das @extended Flag kann den GPSTATUS-Fehlercode ($GPID_ERR* siehe GDIPlusConstants.au3) enthalten. |
Wenn man mit dem Objekt fertig ist, sollte man _GDIPlus_ImageDispose() aufrufen um die Objektressourcen wieder freizugeben.
Suche nach GdipCreateBitmapFromScan0 in der MSDN Bibliothek.
#include <GDIPlus.au3>
Example()
Func Example()
_GDIPlus_Startup()
Local Const $iW = 460, $iH = 100
Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) ;create an empty bitmap
Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;get the graphics context of the bitmap
_GDIPlus_GraphicsSetSmoothingMode($hBmpCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
_GDIPlus_GraphicsClear($hBmpCtxt, 0xFFFFFFFF) ;clear bitmap with color white
_GDIPlus_GraphicsDrawString($hBmpCtxt, "AutoIt rulez!", 0, 0, "Comic Sans MS", 52) ;draw some text to the bitmap
Local $sFile = @TempDir & "\Test.jpg"
_GDIPlus_ImageSaveToFile($hBitmap, $sFile) ;save bitmap to disk
;cleanup GDI+ resources
_GDIPlus_GraphicsDispose($hBmpCtxt)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_Shutdown()
ShellExecute($sFile) ;open bitmap with default app
EndFunc ;==>Example
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
Example()
Func Example()
_GDIPlus_Startup()
Local Const $iW = 120, $iH = 80
Local $hGui = GUICreate("", $iW, $iH)
GUISetState()
Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
Local $tPixel = DllStructCreate("uint[" & $iW * $iH & "];")
Local $iOffset
For $y = 0 To $iH - 1
$iOffset = $y * $iW
For $x = 0 To $iW - 1
DllStructSetData($tPixel, 1, BitOR(0xFF000000, BitShift(Random(0, 255, 1), -16), BitShift(Random(0, 255, 1), -8), Random(0, 255, 1)), $iOffset + $x + 1)
Next
Next
Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH, $GDIP_PXF32ARGB, $iW, $tPixel)
_GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $GUI_EVENT_RESTORE
; um das Bitmap neu zu zeichnen
_GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
EndSwitch
WEnd
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown()
EndFunc ;==>Example