NassauSky Posted March 28 Share Posted March 28 Is there a way to convert the $BMP created by BMP.au3 onto a GUI without saving it to file first? expandcollapse popup;Based on an example by RazerM: #include <BMP3.au3> #include <GDIPlus.au3> $BMP=_BMPCreate(150,150) For $x=0 to 50 For $y=0 to 50 _PixelWrite($BMP,$x,$y,'0000FF') ;blue Next Next For $x=100 to 150 For $y=0 to 50 _PixelWrite($BMP,$x,$y,'ff0000') ;red Next Next For $x=100 to 150 For $y=100 to 150 _PixelWrite($BMP,$x,$y,'00ff00') ;green Next Next For $x=0 to 50 For $y=100 to 150 _PixelWrite($BMP,$x,$y,'000000') ;black Next Next For $x=50 to 100 For $y=50 to 100 _PixelWrite($BMP,$x,$y,'999999') ;grey Next Next ;_BMPWrite($BMP,@ScriptDir & "\MyBMP.bmp");Closes the BMP to a file Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($Bmp) _WinAPI_DeleteObject($Bmp) Local $hGUI = GUICreate("Example", 800, 800) GUISetState() Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0) Do $msg = GUIGetMsg() Until $msg = -3;$GUI_EVENT_CLOSE Link to comment Share on other sites More sharing options...
Solution Nine Posted March 29 Solution Share Posted March 29 Just use GDI+. I do not know this UDF, but it seems to create a .bmp file from scratch. #include <GDIPlus.au3> #include <GUIConstants.au3> _GDIPlus_Startup() Local $hBitmap = _GDIPlus_BitmapCreateFromScan0(200, 200) Local $tBitmapData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, 200, 200, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB) Local $iScan0 = DllStructGetData($tBitmapData, "Scan0") Local $tPixel = DllStructCreate("int[" & 200 * 200 & "];", $iScan0) PixelWrite($tPixel, 200, 0, 0, 99, 99, 0xFFFF0000) PixelWrite($tPixel, 200, 100, 0, 199, 99, 0xFF00FF00) PixelWrite($tPixel, 200, 0, 100, 99, 199, 0xFF0000FF) PixelWrite($tPixel, 200, 100, 100, 199, 199, 0xFF00FFFF) _GDIPlus_BitmapUnlockBits($hBitmap, $tBitmapData) Local $hGUI = GUICreate("Example", 200, 200) GUISetState() Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() Func PixelWrite(ByRef $tStruc, $iWidth, $iXs, $iYs, $iXe, $iYe, $nColor) For $j = $iYs To $iYe $iRowOffset = $j * $iWidth + 1 For $i = $iXs To $iXe DllStructSetData($tStruc, 1, $nColor, $iRowOffset + $i) Next Next EndFunc NassauSky 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now