 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
tic
Joined: 22 Apr 2007 Posts: 1364
|
|
| Back to top |
|
 |
Trikster
Joined: 15 Jul 2007 Posts: 1187 Location: Enterprise, Alabama
|
Posted: Wed May 28, 2008 3:36 am Post subject: |
|
|
Examples?
Or please get in the IRC. _________________ ScriptPad/~dieom/dieom/izwian2k7/Ian/God
 |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1364
|
Posted: Wed May 28, 2008 3:42 am Post subject: |
|
|
Well the 1st example I have just posted is how to set a pixel to any colour in an image and save it as any filetype:
| Code: | #SingleInstance, Force
SetBatchLines, -1
SetWorkingDir %A_ScriptDir%
#Include Gdip.ahk
pToken := Gdip_Startup()
pBitmap := Gdip_CreateBitmapFromFile("in.png")
Gdip_SetPixel(pBitmap, 100, 100, 0xffff0000)
Gdip_SaveBitmap(pBitmap, "out.png")
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
ExitApp
Return |
Very simple example, but more will come. If you see one you like the look of then ask and I'm sure I'll already have an existing example lying around |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1364
|
Posted: Sat May 31, 2008 1:37 am Post subject: |
|
|
Example 1 released: This will create a "screensaver" like effect by drawing random circles on the screen, that are randomly filled with different hatched brushes.
Gdip updated to 1.01 |
|
| Back to top |
|
 |
Guest
|
Posted: Sat May 31, 2008 2:12 pm Post subject: |
|
|
| I just d/l and ran it, and... - nothing happens. |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1364
|
Posted: Sat May 31, 2008 10:42 pm Post subject: |
|
|
| Which OS are you on? If you are Win2000 then you will also need to download gdiplus.dll from the 1st post. Please redownload the example and library |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1364
|
Posted: Sun Jun 01, 2008 9:56 pm Post subject: |
|
|
Please download version 1.02 of the library! There are more than just cosmetic changes.
Also example 2 has been added. Could people please repond with how they useful/hard they are finding them or else I don't know if there's any point continuing!
Example 2 will show you how to create a bitmap, fill it with shapes and save to any supported filetype |
|
| Back to top |
|
 |
k3ph
Joined: 21 Jul 2006 Posts: 127
|
Posted: Mon Jun 02, 2008 3:13 am Post subject: |
|
|
| fast & furious gdi+ manipulation! |
|
| Back to top |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2419
|
Posted: Mon Jun 02, 2008 5:08 am Post subject: |
|
|
Cool  |
|
| Back to top |
|
 |
heresy
Joined: 11 Mar 2008 Posts: 291
|
Posted: Thu Jun 12, 2008 5:07 pm Post subject: |
|
|
thanks for sharing this well organized library and kind tutorials
gdi is always been an inviolable area for beginners (non-programmers)
seems it will take me to the sweet gdi world
i like the tutorials
Thanks tic!! _________________ Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1364
|
Posted: Fri Jun 13, 2008 12:06 am Post subject: |
|
|
Thank you for your kind words. As there is at least some enthusiasm ( ) I have decided to rejiggle the examples. I have made a new 1st example and moved the other ones onwards. The new example is much easier to understand. The same method is used for any gui using gdi+
Please comment if you want some more examples at this level! I guarantee anyone else can be a master of gdi+ in a matter of hours! |
|
| Back to top |
|
 |
heresy
Joined: 11 Mar 2008 Posts: 291
|
Posted: Fri Jun 13, 2008 1:39 am Post subject: |
|
|
people like me who never learn gdi before, must try 1st tutorial on top post.
after following 1st tutorial with 0% knowledge of gdi.
i could draw a frame, filled rectangle in only 20 mins
how easy tic made it for us. this is awesome
thank you so much tic _________________ Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com |
|
| Back to top |
|
 |
Rhys
Joined: 17 Apr 2007 Posts: 730 Location: Florida
|
Posted: Fri Jun 13, 2008 6:03 am Post subject: |
|
|
Tic, I'm gonna go through your examples tomorrow - Here's the video I mentioned of the press+hold for right click in vista - The quality is crap but you can see what I'm talking about at least: http://www.youtube.com/watch?v=uvJE7vgw3ts
That's what I'd like to try to emulate once I get better. Difficulty on a scale of 1-10? _________________ [Join IRC!]
 |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1364
|
Posted: Fri Jun 13, 2008 10:52 am Post subject: |
|
|
I've watched the video. If you need a custom texture on the circle as in that example then its a 7/10 but if you just want to draw a circle and fill it with a brush (can be a pre-textured brush) then 3/10. I'll get onto giving an example soon...
Edit:
I have updated the library again. Make sure you always have the latest one!
There is another simple example now using pens rather than brushes! |
|
| Back to top |
|
 |
Rhys
Joined: 17 Apr 2007 Posts: 730 Location: Florida
|
Posted: Tue Jun 24, 2008 3:55 am Post subject: |
|
|
What I've gotten so far... Hold Shift down to draw a circle around your mouse - It will stay as long as you hold shift.
Forgive the code, still testing (even if I'm just hacking up tic's example)!
| Code: | #SingleInstance, Force
#NoEnv
SetBatchLines, -1
; Uncomment if Gdip.ahk is not in your standard library
#Include, Gdip.ahk
Return
~Shift::
; Start gdi+
If !pToken := Gdip_Startup()
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
ExitApp
}
OnExit, Exit
; Set the width and height we want as our drawing area, to draw everything in. This will be the dimensions of our bitmap
Width := 56, Height := 56
;Width := A_ScreenWidth, Height := A_ScreenHeight
; Create a layered window (+E0x80000 : must be used for UpdateLayeredWindow to work!) that is always on top (+AlwaysOnTop), has no taskbar entry or caption
Gui, 1: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
; Show the window
Gui, 1: Show, NA
; Get a handle to this window we have created in order to update it later
hwnd1 := WinExist()
; Create a gdi bitmap with width and height of what we are going to draw into it. This is the entire drawing area for everything
hbm := CreateDIBSection(Width, Height)
; Get a device context compatible with the screen
hdc := CreateCompatibleDC()
; Select the bitmap into the device context
obm := SelectObject(hdc, hbm)
; Get a pointer to the graphics of the bitmap, for use with drawing functions
G := Gdip_GraphicsFromHDC(hdc)
; Set the smoothing mode to antialias = 4 to make shapes appear smother (only used for vector drawing and filling)
Gdip_SetSmoothingMode(G, 4)
; Create a fully opaque red brush (ARGB = Transparency, red, green, blue) to draw a circle
hBrush := Gdip_BrushCreateSolid(0xffff0000)
; Fill the graphics of the bitmap with an ellipse using the brush created
; Filling from coordinates (100,50) an ellipse of 200x300
;Gdip_FillEllipse(G, hBrush, 100, 50, 600, 600)
; Delete the brush as it is no longer needed and wastes memory
Gdip_DeleteBrush(hBrush)
; Create a slightly transparent (66) blue brush (ARGB = Transparency, red, green, blue) to draw a rectangle
hBrush := Gdip_BrushCreateSolid(0x660000ff)
hBrush:=Gdip_BrushCreateHatch(0x660000ff, 0xff0000ff, 47)
; Fill the graphics of the bitmap with a rectangle using the brush created
; Filling from coordinates (250,80) a rectangle of 300x200
;Gdip_FillRectangle(G, hBrush, 250, 80, 300, 200)
; Delete the brush as it is no longer needed and wastes memory
Gdip_DeleteBrush(hBrush)
hBrush:=Gdip_BrushCreateSolid(0xEEff0000)
hPen:=Gdip_CreatePen(0xEEFFFFee0, 2)
fatPen:=Gdip_CreatePen(0xEE0000FF, 5)
CoordMode, Mouse, Screen
Loop,60
{
GetKeyState,State,Shift,P
If State = U
Break
MouseGetPos,MX,MY
;Gdip_DrawArc(pGraphics, hPen, x, y, w, h, StartAngle, SweepAngle)
Gdip_SetCompositingMode(G, 1)
Gdip_Drawarc(G, FatPen, 2, 2, 50, 50, 270, A_Index*6)
Gdip_SetCompositingMode(G, 0)
Gdip_Drawarc(G, hPen, 2, 2, 50, 50, 270, A_Index*6)
UpdateLayeredWindow(hwnd1, hdc, MX-25, MY-25, Width, Height)
Sleep,10
}
Gdip_SetCompositingMode(G, 0)
Loop,
{
GetKeyState,State,Shift,P
If State = U
Break
MouseGetPos,MX,MY
UpdateLayeredWindow(hwnd1, hdc, MX-25, MY-25, Width, Height)
Sleep,10
}
; Update the specified window we have created (hwnd1) with a handle to our bitmap (hdc), specifying the x,y,w,h we want it positioned on our screen
; So this will position our gui at (0,0) with the Width and Height specified earlier
;UpdateLayeredWindow(hwnd1, hdc, 0, 0, Width, Height)
Gui,Destroy
; Select the object back into the hdc
SelectObject(hdc, obm)
; Now the bitmap may be deleted
DeleteObject(hbm)
; Also the device context related to the bitmap may be deleted
DeleteDC(hdc)
; The graphics may now be deleted
Gdip_DeleteGraphics(G)
Return
;#######################################################################
Esc::
Exit:
; gdi+ may now be shutdown on exiting the program
Gdip_Shutdown(pToken)
ExitApp
Return |
_________________ [Join IRC!]
 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|