corgano Posted March 6, 2009 Share Posted March 6, 2009 i have looked and could not find a thread about this how would i make a blank picture ( jpg, png, bmp, doesnt really matter ) and then draw a square on it in autoit? what func do i use? is there a udf? 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
maqleod Posted March 6, 2009 Share Posted March 6, 2009 i have looked and could not find a thread about thishow would i make a blank picture ( jpg, png, bmp, doesnt really matter ) and then draw a square on it in autoit?what func do i use? is there a udf?you might try looking at the GDIPlus and WinAPI UDFs [u]You can download my projects at:[/u] Pulsar Software Link to comment Share on other sites More sharing options...
corgano Posted March 10, 2009 Author Share Posted March 10, 2009 you might try looking at the GDIPlus and WinAPI UDFsi found the winapi udfs uselessthe gdi + udf's could be usefull but i cant find out how to use them. 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
BlackScorpion Posted March 10, 2009 Share Posted March 10, 2009 open the UDFs3.chm help file located in the Autoit3 install directory _GDIPlus_GraphicsDrawRect <-- look for this ======== example provided in help file !!! pretty much what you want to do ============== #include <GDIPlus.au3> #include <ScreenCapture.au3> #include <WinAPI.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphics ; Initialize GDI+ library _GDIPlus_Startup () ; Capture full screen $hBitmap1 = _ScreenCapture_Capture ("") $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap1) ; Capture screen region $hBitmap2 = _ScreenCapture_Capture ("", 0, 0, 400, 300) $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap2) ; Draw one image in another $hGraphics = _GDIPlus_ImageGetGraphicsContext ($hImage1) _GDIPlus_GraphicsDrawImage ($hGraphics, $hImage2, 100, 100) ; Draw a frame around the inserted image _GDIPlus_GraphicsDrawRect ($hGraphics, 100, 100, 400, 300) ; Save resultant image _GDIPlus_ImageSaveToFile ($hImage1, @MyDocumentsDir & "\GDIPlus_Image.jpg") ; Clean up resources _GDIPlus_ImageDispose ($hImage1) _GDIPlus_ImageDispose ($hImage2) _WinAPI_DeleteObject ($hBitmap1) _WinAPI_DeleteObject ($hBitmap2) ; Shut down GDI+ library _GDIPlus_ShutDown () EndFunc ;==>_Main Link to comment Share on other sites More sharing options...
bo8ster Posted March 10, 2009 Share Posted March 10, 2009 I know there was a thread a few weeks, maybe a month ago on this. Try searching. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
AlmarM Posted March 10, 2009 Share Posted March 10, 2009 Mayby you could take a look at Graphics. #include <GUIConstants.au3> $GUI = GUICreate("Square Example", 300, 300) $Square = GUICtrlCreateGraphic(50, 50, 100, 100) GUICtrlSetGraphic($Square, $GUI_GR_COLOR, 0x000000, 0x000000) GUICtrlSetGraphic($Square, $GUI_GR_RECT, 50, 50, 100, 100) GUICtrlSetGraphic($Square, $GUI_GR_REFRESH) GUICtrlSetGraphic($Square, $GUI_GR_CLOSE) GUISetState() While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit WEnd AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
corgano Posted March 16, 2009 Author Share Posted March 16, 2009 (edited) open the UDFs3.chm help file located in the Autoit3 install directory_GDIPlus_GraphicsDrawRect <-- look for this ======== example provided in help file !!! pretty much what you want to do ==============#include <GDIPlus.au3>#include <ScreenCapture.au3>#include <WinAPI.au3>Opt('MustDeclareVars', 1)_Main()Func _Main() Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphics ; Initialize GDI+ library _GDIPlus_Startup () ; Capture full screen $hBitmap1 = _ScreenCapture_Capture ("") $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap1) ; Capture screen region $hBitmap2 = _ScreenCapture_Capture ("", 0, 0, 400, 300) $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap2) ; Draw one image in another $hGraphics = _GDIPlus_ImageGetGraphicsContext ($hImage1) _GDIPlus_GraphicsDrawImage ($hGraphics, $hImage2, 100, 100) ; Draw a frame around the inserted image _GDIPlus_GraphicsDrawRect ($hGraphics, 100, 100, 400, 300) ; Save resultant image _GDIPlus_ImageSaveToFile ($hImage1, @MyDocumentsDir & "\GDIPlus_Image.jpg") ; Clean up resources _GDIPlus_ImageDispose ($hImage1) _GDIPlus_ImageDispose ($hImage2) _WinAPI_DeleteObject ($hBitmap1) _WinAPI_DeleteObject ($hBitmap2) ; Shut down GDI+ library _GDIPlus_ShutDown ()EndFunc ;==>_Mainhow do i draw just the rectangle? the output must be a bitmap file, not a guii looked in the help file. couldnt find since it needs something to draw on, it his script it was a screenshot. Edited March 16, 2009 by corgano 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
Malkey Posted March 16, 2009 Share Posted March 16, 2009 how do i draw just the rectangle? the output must be a bitmap file, not a gui i looked in the help file. couldnt find since it needs something to draw on, it his script it was a screenshot.This example creates a bitmap and draws a rectangle with a border. Then, the image is saved as a bmp file in the script directory. expandcollapse popup#include <GDIPlus.au3> #include <WinAPI.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $hBitmap1, $hImage1, $hGraphics, $hBrush, $hPen ; Initialize GDI+ library _GDIPlus_Startup() ; Create bitmap $hBitmap1 = _WinAPI_CreateBitmap(600, 500, 1, 32) $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap1) $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage1) _GDIPlus_GraphicsClear($hGraphics, 0xFF80FF80); Background colour 0xAARRGGBB format. _GDIPlus_GraphicsDrawImage($hGraphics, $hImage1, 100, 100) ; Draw rectangle $hBrush = _GDIPlus_BrushCreateSolid(0xFF8080FF); rectangle colour 0xAARRGGBB format. _GDIPlus_GraphicsFillRect($hGraphics, 100, 100, 400, 300, $hBrush) ; Draw a frame around the rectangle $hPen = _GDIPlus_PenCreate(0xFFFF0000, 4); fully opaque, red _GDIPlus_GraphicsDrawRect($hGraphics, 100, 100, 400, 300, $hPen) ; Save resultant image _GDIPlus_ImageSaveToFile($hImage1, @ScriptDir & "\GDIPlus_Image.bmp") ; Clean up resources _GDIPlus_ImageDispose($hImage1) _WinAPI_DeleteObject($hBitmap1) _GDIPlus_BrushDispose($hBrush) _GDIPlus_PenDispose($hPen) ; Shut down GDI+ library _GDIPlus_Shutdown() ShellExecute(@ScriptDir & "\GDIPlus_Image.bmp") EndFunc ;==>_Main 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