cppman Posted March 19, 2006 Share Posted March 19, 2006 I was working on a little project and was wondering if you can Draw a pixel or something onto a GUI without having it have to be in a Graphic Control? Any UDF's for doing this? Miva OS Project Link to comment Share on other sites More sharing options...
nfwu Posted March 19, 2006 Share Posted March 19, 2006 Don't think so, though for my latest version of AutoIt3D, I used a single graphics control for the whole screen #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
cppman Posted March 19, 2006 Author Share Posted March 19, 2006 (edited) Well, then is their a way to load an image into a graphics control? -becuase im trying to draw PIXELS over an IMAGE Edited March 19, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
nfwu Posted March 19, 2006 Share Posted March 19, 2006 Yes... I'm going to look it up in my scriptsAndScraps folder... #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
nfwu Posted March 19, 2006 Share Posted March 19, 2006 Something I found: expandcollapse popup#include <GUIConstants.au3> $timer = TimerInit() $szPicFile = FileOpenDialog( "Choose bitmap", @DesktopDir, "All Files (*.*)" ) Const $GWL_HINSTANCE = -6 Const $IMAGE_BITMAP = 0 Const $LR_LOADFROMFILE = 0x0010 $dimension = _ImageGetSize ($szPicFile) GUICreate("Example Drawing", $dimension[0] + 100, $dimension[1] + 100) $lbSta = GUICtrlCreateLabel("Loading...", 20, 80) GUISetState(@SW_SHOW) GUICtrlCreateGraphic(0, 0, $dimension[0], $dimension[1]);width height Dim $hInst, $hBmp, $hMemDC, $hwnd opt("WinWaitDelay", 1) AutoItWinSetTitle("qqqqqq") $hwnd = WinGetHandle("qqqqqq") $hInst = DllCall("user32.dll", "int", "GetWindowLong", "hWnd", $hwnd, "int", $GWL_HINSTANCE) $hInst = $hInst[0] $hBmp = DllCall("user32.dll", "hwnd", "LoadImage", "hwnd", $hInst, "str", $szPicFile, "int", $IMAGE_BITMAP, _ "int", 0, "int", 0, "int", $LR_LOADFROMFILE) $hBmp = $hBmp[0] $hMemDC = DllCall("gdi32.dll", "int", "CreateCompatibleDC", "int", 0) $hMemDC = $hMemDC[0] DllCall("gdi32.dll", "hwnd", "SelectObject", "int", $hMemDC, "hwnd", $hBmp) For $y = 0 To $dimension[1] - 1 For $x = 0 To $dimension[0] - 1 $ret = DllCall("gdi32.dll", "int", "GetPixel", "int", $hMemDC, "int", $x, "int", $y) $ret = Hex($ret[0], 6) $ret = StringRight($ret, 2) & StringMid($ret, 3, 2) & StringLeft($ret, 2) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, Dec($ret)) GUICtrlSetGraphic(-1, $GUI_GR_PIXEL, $x, $y) ;If Mod($y, 50) = 0 And $x = 0 Then GUICtrlSetGraphic(-1, $GUI_GR_REFRESH) Next Next GUICtrlSetGraphic(-1, $GUI_GR_REFRESH) DllCall("gdi32.dll", "int", "DeleteDC", "hwnd", $hMemDC) DllCall("gdi32.dll", "int", "DeleteObject", "hwnd", $hBmp) GUICtrlSetData($lbSta, "Finished.") MsgBox( 0, "Timer - Image Drawer", TimerDiff( $timer ) ) While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd #region - LazyCat;SEE THE FUNCTIONS WRITTEN BY LazyCat ;http://www.autoitscript.com/forum/index.php?s=&showtopic=4159&view=findpost&p=27240 Func _ImageGetSize ($sFile) Local $sHeader = _FileReadAtOffsetHEX ($sFile, 1, 24); Get header bytes Local $asIdent = StringSplit("FFD8 424D 89504E470D0A1A 4749463839 4749463837 4949 4D4D", " ") Local $anSize = "" If $asIdent[0] >= 2 And StringInStr($sHeader, $asIdent[2]) = 1 Then Return _ImageGetSizeSimple ($sHeader, 19, 23, 0) EndIf EndFunc ;FUNCTION WRITTEN BY LazyCat Func _FileReadAtOffsetHEX ($sFile, $nOffset, $nBytes) Local $hFile = FileOpen($sFile, 0) Local $sTempStr = "" FileRead($hFile, $nOffset - 1) For $i = $nOffset To $nOffset + $nBytes - 1 $sTempStr = $sTempStr & Hex(Asc(FileRead($hFile, 1)), 2) Next FileClose($hFile) Return ($sTempStr) EndFunc ;FUNCTION WRITTEN BY LazyCat Func _ImageGetSizeSimple ($sHeader, $nXoff, $nYoff, $nByteOrder) Local $anSize[2] $anSize[0] = _Dec (StringMid($sHeader, $nXoff * 2 - 1, 4), $nByteOrder) $anSize[1] = _Dec (StringMid($sHeader, $nYoff * 2 - 1, 4), $nByteOrder) Return ($anSize) EndFunc ;FUNCTION WRITTEN BY LazyCat Func _Dec ($sHexStr, $nByteOrder) If $nByteOrder Then Return (Dec($sHexStr)) Local $sTempStr = "" While StringLen($sHexStr) > 0 $sTempStr = $sTempStr & StringRight($sHexStr, 2) $sHexStr = StringTrimRight($sHexStr, 2) WEnd Return (Dec($sTempStr)) EndFunc #endregion TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
cppman Posted March 19, 2006 Author Share Posted March 19, 2006 I Get an error every time after i choose the image to load.... Array size exceeded... Miva OS Project Link to comment Share on other sites More sharing options...
nfwu Posted March 19, 2006 Share Posted March 19, 2006 did you load a *.bmp file? #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
cppman Posted March 19, 2006 Author Share Posted March 19, 2006 (edited) oh.. it only works with bitmaps.. hmm, pretty cool. Thanks. Edited March 19, 2006 by CHRIS95219 Miva OS Project 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