Jump to content
Sign in to follow this  
corgano

help drawing

Recommended Posts

corgano

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

Share this post


Link to post
Share on other sites
maqleod

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?

you might try looking at the GDIPlus and WinAPI UDFs


[u]You can download my projects at:[/u] Pulsar Software

Share this post


Link to post
Share on other sites
corgano

you might try looking at the GDIPlus and WinAPI UDFs

i found the winapi udfs useless

the gdi + udf's could be usefull but i cant find out how to use them.


0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites
BlackScorpion

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

Share this post


Link to post
Share on other sites
bo8ster

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]

Share this post


Link to post
Share on other sites
AlmarM

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.

Share this post


Link to post
Share on other sites
corgano

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

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.

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites
Malkey

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.

#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

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.