 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Zaelia
Joined: 31 Oct 2008 Posts: 604 Location: France
|
Posted: Wed Feb 17, 2010 9:42 pm Post subject: |
|
|
Thanks a lot Tic
I do some test, they aren't big differences on a normal computer (3 years old /win vista / media config and medium), each method have a lot of benefits...
But with a mini PC ( 2 years old / win XP / work config and small ), GDIDrawImage with UpdateLayer is AWSOME! CPU usage is tiny ! |
|
| Back to top |
|
 |
Razer
Joined: 15 Feb 2010 Posts: 10
|
Posted: Thu Feb 18, 2010 8:50 am Post subject: |
|
|
Thx Tic and Zaelia for this feedback about cpu usage and best way to draw image.
Razer. |
|
| Back to top |
|
 |
Razer
Joined: 15 Feb 2010 Posts: 10
|
Posted: Fri Feb 19, 2010 10:06 am Post subject: |
|
|
Hi Tic,
I've tried to follow your advice and work with clipped region to have only some part of my graphics updated.
Here is the code :
| Code: |
; --------------------------------------------------------------------------------------------------
; GENERAL SETTINGS
; --------------------------------------------------------------------------------------------------
#noenv
setbatchlines -1
listlines Off
#singleinstance force
#include Gdip.ahk
settimer UpdateLabel, 200
onexit ExitLabel
; --------------------------------------------------------------------------------------------------
; DEFINITIONS
; --------------------------------------------------------------------------------------------------
GUI_BG := 40
WIN_BG := "WIN_BACKGROUND"
WIN_ID_BG := "Background"
skin_file = %A_ScriptDir%\Skin.png
p_bitmap := ""
initialize()
; --------------------------------------------------------------------------------------------------
; FONCTIONS
; --------------------------------------------------------------------------------------------------
initialize()
{
global
local retour := 0
if !pToken := Gdip_Startup()
{
msgbox 48, initialize : Gdiplus failed to start. Please ensure you have gdiplus on your system
ExitApp
}
init_background()
return retour
}
init_background()
{
global
local retour := 0
; 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 %GUI_BG%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
; Show the window
gui %GUI_BG%:show, NA, %WIN_BG%
; Get a handle to this window we have created in order to update it later
WIN_ID_BG := WinExist()
update_layer( WIN_ID_BG )
return retour
}
update_layer( layer_name )
{
global
local retour := 0
local font := ""
local options = ""
local current_time := ""
local current_seconds := ""
static x_win := 0
static x_win := 0
static w_win := 0
static h_win := 0
wingetpos x_win, y_win, w_win, h_win, ahk_id %WIN_ID_BG%
if ( x_win < 0 )
{
x_win := 0
}
if ( y_win < 0 )
{
y_win := 0
}
; ----------------------------------
; Creation of the graphic ressources
; ----------------------------------
hbm := CreateDIBSection(160, 80)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
p_graphic := Gdip_GraphicsFromHDC(hdc)
Gdip_SetInterpolationMode(p_graphic, 7)
; ---------------------------------
; Loading of the background picture
; ---------------------------------
if ( layer_name == WIN_ID_BG )
{
p_bitmap := Gdip_CreateBitmapFromFile( skin_file )
if !p_bitmap
{
MsgBox, 48, update_layer : Could not load the image <%skin_file%>
ExitApp
}
Gdip_DrawImage(p_graphic, p_bitmap, 0, 0, 160, 80, 0, 0, 160, 80)
}
; -------------------------------
; Update of the foreground window
; -------------------------------
if ( layer_name == WIN_ID_FG )
{
font := "Arial"
options = x0 y40 w160 h0 cFFFF5050 Center Normal r4 s18
formattime current_time,, HH:mm:ss
; Define the working Area
Gdip_SetClipRect(p_graphic, 0, 40, 160, 18)
; Gdip_SetCompositingMode to 1 so that it will erase anything that is currently there
Gdip_SetCompositingMode(p_graphic, 1)
Gdip_DrawImage(p_graphic, p_bitmap, 0, 0, 160, 80, 0, 0, 160, 80)
; Gdip_SetCompositingMode back to 0 so that the fish are drawn onto the background and dont erase it
Gdip_SetCompositingMode(p_graphic, 0)
; Gdip_SetCompositingMode(p_graphic, 0)
Gdip_TextToGraphics(p_graphic, current_time, options, font)
}
; --------------------
; Update of the window
; --------------------
UpdateLayeredWindow(WIN_ID_BG, hdc, x_win, y_win, 160, 80)
Gdip_ResetClip(p_graphic)
; ------------------------------
; Handle of the left mouse click
; ------------------------------
OnMessage(0x201, "WM_LBUTTONDOWN")
; -------------------------
; Delete graphic ressources
; -------------------------
SelectObject(hdc, obm)
DeleteObject(hbm)
DeleteDC(hdc)
Gdip_DeleteGraphics(p_graphic)
return retour
}
; --------------------------------------------------------------------------------------------------
; LABELS
; --------------------------------------------------------------------------------------------------
UpdateLabel:
update_layer( WIN_ID_FG )
return
ExitLabel:
; -------------------------
; Delete graphic ressources
; -------------------------
Gdip_DisposeImage(p_bitmap)
Gdip_Shutdown(pToken)
ExitApp
return
WM_LBUTTONDOWN()
{
PostMessage, 0xA1, 2
}
|
Here is the ressources :
http://stashbox.org/800264/ClippingMethod.zip
I must have made a mistake because instead of having all the background bitmap, I only have the part within the clipped region.
Here is what I was looking to do :
----------------------------
Only at the initialisation :
----------------------------
Load background bitmap.
Draw background bitmap only once.
Update of the layered window.
-------------------------------
When text needs to be updated :
-------------------------------
Select region to be updated.
Draw part of the background bitmap within this clipped region.
Draw dynamic text within this clipped region.
Update of the layered window.
Can you figure out where is my mistake?
Razer. |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Fri Feb 19, 2010 6:11 pm Post subject: |
|
|
Dear tic,
Once a hBitmap has been send to a control with | Code: | | SetImage(hwnd, hBitmap) | how can this bitmap be removed later on without shrinking the control?
I tried GuiControl. But that didn't remove the bitmap. Also didn't do the trick, since it shrink the control to nothing (width = height = 0). And I wasn't able to find anything in your example. Could you please give an advice? Thanks a lot. _________________ Ciao
toralf  |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1786
|
Posted: Sat Feb 20, 2010 6:23 pm Post subject: |
|
|
Razer
I will look at your code shortly and see whats going wrong
Toralf
Heres a new function for you to play with:
| Code: |
GuiControlGet, hwnd, hwnd, VariableOfControl
SetSysColorToControl(hwnd)
return
;#######################################################################
SetSysColorToControl(hwnd, SysColor=15)
{
WinGetPos,,, w, h, ahk_id %hwnd%
bc := DllCall("GetSysColor", "Int", SysColor)
pBrushClear := Gdip_BrushCreateSolid(0xff000000 | (bc >> 16 | bc & 0xff00 | (bc & 0xff) << 16))
pBitmap := Gdip_CreateBitmap(w, h), G := Gdip_GraphicsFromImage(pBitmap)
Gdip_FillRectangle(G, pBrushClear, 0, 0, w, h)
hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
SetImage(hwnd, hBitmap)
Gdip_DeleteBrush(pBrushClear)
Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmap), DeleteObject(hBitmap)
return 0
}
|
The default is 15, which is COLOR_3DFACE. should add GetSysColor to the library... |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1786
|
Posted: Sat Feb 20, 2010 11:16 pm Post subject: |
|
|
I would encourage anyone with the ability to take a look and try and help with:
GDI+ Save Icon to PNG Trouble...
as I would like to include this in the next release of the library
Thanks |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Sun Feb 21, 2010 1:31 pm Post subject: |
|
|
Hi tic,
Thanks a lot. That did it. Very much appreciated. _________________ Ciao
toralf  |
|
| Back to top |
|
 |
Smurth
Joined: 13 Dec 2006 Posts: 117
|
Posted: Sun Feb 28, 2010 2:01 am Post subject: |
|
|
I think I've found a mistake in Gdip_FillRoundedRectangle.
Rounded rectangle looks much rounded when padding -1 the right, bottom and bottom-right ellipse.
Here is the new Gdip_FillRoundedRectangle:
| Code: | Gdip_FillRoundedRectangle(pGraphics, pBrush, x, y, w, h, r)
{
Region := Gdip_GetClipRegion(pGraphics)
Gdip_SetClipRect(pGraphics, x-r, y-r, 2*r, 2*r, 4)
Gdip_SetClipRect(pGraphics, x+w-r, y-r, 2*r, 2*r, 4)
Gdip_SetClipRect(pGraphics, x-r, y+h-r, 2*r, 2*r, 4)
Gdip_SetClipRect(pGraphics, x+w-r, y+h-r, 2*r, 2*r, 4)
E := Gdip_FillRectangle(pGraphics, pBrush, x, y, w, h)
Gdip_SetClipRegion(pGraphics, Region, 0)
Gdip_SetClipRect(pGraphics, x-(2*r), y+r, w+(4*r), h-(2*r), 4)
Gdip_SetClipRect(pGraphics, x+r, y-(2*r), w-(2*r), h+(4*r), 4)
Gdip_FillEllipse(pGraphics, pBrush, x, y, 2*r, 2*r)
Gdip_FillEllipse(pGraphics, pBrush, x+w-(2*r)-1, y, 2*r, 2*r)
Gdip_FillEllipse(pGraphics, pBrush, x, y+h-(2*r)-1, 2*r, 2*r)
Gdip_FillEllipse(pGraphics, pBrush, x+w-(2*r)-1, y+h-(2*r)-1, 2*r, 2*r)
Gdip_SetClipRegion(pGraphics, Region, 0)
Gdip_DeleteRegion(Region)
Return E
} |
|
|
| Back to top |
|
 |
Razer
Joined: 15 Feb 2010 Posts: 10
|
Posted: Tue Mar 02, 2010 10:45 am Post subject: |
|
|
Hi Smurth,
Thx for this update. I'm glad you've found this little mistake because it was driving me crazy. I thought it was something to do with the render parameter of gdip I was misusing.
Tested and now it works great. Rounded rectangles look indeed much rounded with your little correction.
The more I use the gdip library of Tic the more I like it and the more I use it. |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1786
|
Posted: Tue Mar 02, 2010 2:17 pm Post subject: |
|
|
If there is a problem with the rounded rectangle function, then Im not sure that just subtracting one is the solution. the reason youd see any offset of pixels will be due to the smoothing mode.
Taken directly from tutorial 8 with no modifications:
Left is with Smurths alteration, and the right one is the using the function currently in the library. You can clearly see that the one on the left is one pixel off
I have an updated library that I havent released yet as it has quite a few new things in it. I have rewritten parts of the library for c# and simplified it for easy use for myself. If anyone is interested then I may also release that (although there is wpf with hardware acceleration, I find it a pain to use and the code ends up being massive with it) |
|
| Back to top |
|
 |
Smurth
Joined: 13 Dec 2006 Posts: 117
|
Posted: Tue Mar 02, 2010 2:54 pm Post subject: |
|
|
I'm not claming I've found THE solution. However, the "one pixel off" on the image can not come from the alterations I've made. I've only touched the way ellipses are drawn; not the rectangle.
So, my workaround can not produce the image you've posted, Tic. And, with little value for "r", it produces better rounded corners; even if not perfect. |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1786
|
Posted: Tue Mar 02, 2010 3:20 pm Post subject: |
|
|
of course it can create that image. the ellipse has been drawn with the incorrect radius, so does not reach the edge of the rectangle. Im not going to lie about it
| Code: | ; gdi+ ahk tutorial 8 written by tic (Tariq Porter)
; Requires Gdip.ahk either in your Lib folder as standard library or using #Include
;
; Tutorial to write text onto a gui
#SingleInstance, Force
#NoEnv
SetBatchLines, -1
; Uncomment if Gdip.ahk is not in your standard library
;#Include, Gdip.ahk
; 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 := 300, Height := 200
CreateWin(1)
CreateWin(2)
; By placing this OnMessage here. The function WM_LBUTTONDOWN will be called every time the user left clicks on the gui
OnMessage(0x201, "WM_LBUTTONDOWN")
Return
;#######################################################################
CreateWin(Win)
{
global
; 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, %Win%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui, %Win%: Add, Edit, w%Width% h20 y300, vMeEdit
; Show the window
Gui, %Win%: Show, NA
; Get a handle to this window we have created in order to update it later
hwnd%Win% := 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 partially transparent, black brush (ARGB = Transparency, red, green, blue) to draw a rounded rectangle with
pBrush := Gdip_BrushCreateSolid(0xaa000000)
; Fill the graphics of the bitmap with a rounded rectangle using the brush created
; Filling the entire graphics - from coordinates (0, 0) the entire width and height
; The last parameter (20) is the radius of the circles used for the rounded corners
if !Mod(Win, 2)
Gdip_FillRoundedRectangle(G, pBrush, 0, 0, Width, Height, 20)
else
Gdip_FillRoundedRectangle2(G, pBrush, 0, 0, Width, Height, 20)
; Delete the brush as it is no longer needed and wastes memory
Gdip_DeleteBrush(pBrush)
; We can specify the font to use. Here we use Arial as most systems should have this installed
Font = Arial
; Next we can check that the user actually has the font that we wish them to use
; If they do not then we can do something about it. I choose to give a wraning and exit!
If !Gdip_FontFamilyCreate(Font)
{
MsgBox, 48, Font error!, The font you have specified does not exist on the system
ExitApp
}
; There are a lot of things to cover with the function Gdip_TextToGraphics
; The 1st parameter is the graphics we wish to use (our canvas)
; The 2nd parameter is the text we wish to write. It can include new lines `n
; The 3rd parameter, the options are where all the action takes place...
; You can write literal x and y coordinates such as x20 y50 which would place the text at that position in pixels
; or you can include the last 2 parameters (Width and Height of the Graphics we will use) and then you can use x10p
; which will place the text at 10% of the width and y30p which is 30% of the height
; The same percentage marker may be used for width and height also, so w80p makes the bounding box of the rectangle the text
; will be written to 80% of the width of the graphics. If either is missed (as I have missed height) then the height of the bounding
; box will be made to be the height of the graphics, so 100%
; Any of the following words may be used also: Regular,Bold,Italic,BoldItalic,Underline,Strikeout to perform their associated action
; To justify the text any of the following may be used: Near,Left,Centre,Center,Far,Right with different spelling of words for convenience
; The rendering hint (the quality of the antialiasing of the text) can be specified with r, whose values may be:
; SystemDefault = 0
; SingleBitPerPixelGridFit = 1
; SingleBitPerPixel = 2
; AntiAliasGridFit = 3
; AntiAlias = 4
; The size can simply be specified with s
; The colour and opacity can be specified for the text also by specifying the ARGB as demonstrated with other functions such as the brush
; So cffff0000 would make a fully opaque red brush, so it is: cARGB (the literal letter c, follwed by the ARGB)
; The 4th parameter is the name of the font you wish to use
; As mentioned previously, you don not need to specify the last 2 parameters, the width and height, unless
; you are planning on using the p option with the x,y,w,h to use the percentage
Options = x10p y30p w80p Centre cbbffffff r4 s20 Underline Italic
Gdip_TextToGraphics(G, "Tutorial 8`n`nThank you for trying this example", Options, Font, Width, Height)
; 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
; With some simple maths we can place the gui in the centre of our primary monitor horizontally and vertically at the specified heigth and width
UpdateLayeredWindow(hwnd%Win%, hdc, ((A_ScreenWidth-(2*Width))//2)+((Win-1)*(Width+5)), (A_ScreenHeight-Height)//2, Width, Height)
; 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)
}
;#######################################################################
Gdip_FillRoundedRectangle2(pGraphics, pBrush, x, y, w, h, r)
{
Region := Gdip_GetClipRegion(pGraphics)
Gdip_SetClipRect(pGraphics, x-r, y-r, 2*r, 2*r, 4)
Gdip_SetClipRect(pGraphics, x+w-r, y-r, 2*r, 2*r, 4)
Gdip_SetClipRect(pGraphics, x-r, y+h-r, 2*r, 2*r, 4)
Gdip_SetClipRect(pGraphics, x+w-r, y+h-r, 2*r, 2*r, 4)
E := Gdip_FillRectangle(pGraphics, pBrush, x, y, w, h)
Gdip_SetClipRegion(pGraphics, Region, 0)
Gdip_SetClipRect(pGraphics, x-(2*r), y+r, w+(4*r), h-(2*r), 4)
Gdip_SetClipRect(pGraphics, x+r, y-(2*r), w-(2*r), h+(4*r), 4)
Gdip_FillEllipse(pGraphics, pBrush, x, y, 2*r, 2*r)
Gdip_FillEllipse(pGraphics, pBrush, x+w-(2*r)-1, y, 2*r, 2*r)
Gdip_FillEllipse(pGraphics, pBrush, x, y+h-(2*r)-1, 2*r, 2*r)
Gdip_FillEllipse(pGraphics, pBrush, x+w-(2*r)-1, y+h-(2*r)-1, 2*r, 2*r)
Gdip_SetClipRegion(pGraphics, Region, 0)
Gdip_DeleteRegion(Region)
Return E
}
;#######################################################################
; This function is called every time the user clicks on the gui
; The PostMessage will act on the last found window (this being the gui that launched the subroutine, hence the last parameter not being needed)
WM_LBUTTONDOWN()
{
PostMessage, 0xA1, 2
}
;#######################################################################
Exit:
; gdi+ may now be shutdown on exiting the program
Gdip_Shutdown(pToken)
ExitApp
Return |
|
|
| Back to top |
|
 |
Smurth
Joined: 13 Dec 2006 Posts: 117
|
Posted: Tue Mar 02, 2010 4:09 pm Post subject: |
|
|
OK, here is my new shiny Gdip_FillRoundedRectangle:
| Code: | Gdip_FillRoundedRectangle(pGraphics, pBrush, x, y, w, h, r, smoothing=4)
{
B := Gdip_CreateBitmap(w,h)
G := Gdip_GraphicsFromImage(B)
Gdip_SetSmoothingMode(G, smoothing)
Gdip_SetCompositingMode(G, 1)
Gdip_FillEllipse(G, pBrush, 0, 0, 2*r, 2*r)
Gdip_FillEllipse(G, pBrush, w-2*r-1, 0, 2*r, 2*r)
Gdip_FillEllipse(G, pBrush, 0, h-2*r-1, 2*r, 2*r)
Gdip_FillEllipse(G, pBrush, w-2*r-1, h-2*r-1, 2*r, 2*r)
Gdip_SetSmoothingMode(G,0)
Gdip_FillRectangle(G, pBrush, r, 0, w-2*r, h)
Gdip_FillRectangle(G, pBrush, 0, r, w, h-2*r)
Gdip_DrawImage(pGraphics, B, x, y, w, h, 0, 0, w, h)
Gdip_DisposeImage(B)
Gdip_DeleteGraphics(G)
}
|
|
|
| Back to top |
|
 |
jpjazzy
Joined: 16 Feb 2010 Posts: 799 Location: SciTE
|
Posted: Wed Mar 03, 2010 4:18 am Post subject: |
|
|
Hi Tic,
First of all I would just like to say GREAT SCRIPT!
Secondly, I need some help. I want to create a circle which is resized anywhere on the screen when you hit a hotkey (the screen gets slightly whited out so you know its happening and then when you left click that becomes the center of the circle and if you drag outwards it expands. After that the gui is hidden.) Now my problem is that after hitting Alt C (The beginning trigger key) then making the first circle, the left mouse button becomes unresponsive and I can even exit the script because it says it is taking too long and so I have to use task manager (I can left click if I hold down shift to interrupt the autohotkey.)
That being said, after the first initial circle is drawn the other circles wont draw and I have to exit manually, like I said. I think it probably is doing that because I can't use my left mouse button after the initial circle.
I was thinking about why it might be doing this and the only thing I can see is maybe the hwd1 window is still up in the UpdateLayeredWindow gdi function.... is there a way to delete that or some way I can work around it....? Hope you can help me in some way here... Here is my code:
| Code: | ; Requires Gdip.ahk either in your Lib folder as standard library or using #Include
#InstallMouseHook
#SingleInstance, Force
#NoEnv
SetBatchLines, -1
; Uncomment if Gdip.ahk is not in your standard library
#Include, Gdip.ahk
!c::
; 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
;Gui to be the background
Gui, 21: Color, white
Gui, 21:-Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
WinSet, Transparent, 100
Gui, 21: Show, x0 y0 w%A_ScreenWidth% h%A_ScreenHeight%
Hotkey, LButton, Drag
Return
Drag:
; 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
; Set the width and height we want as our drawing area, to draw everything in. This will be the dimensions of our bitmap
Width := A_ScreenWidth
Height := A_ScreenHeight
MouseGetPos, MX, MY
Loop
{
MouseGetPos, NewMX, NewMY
Radius := (MX-NewMX)
Diameter := (Radius*2)
StartX := (MX-Radius)
StartY := (MY-Radius)
; 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 pen (ARGB = Transparency, red, green, blue) of width 3 (the thickness the pen will draw at) to draw a circle
pPen := Gdip_CreatePen(0x55ff0000, 3)
; Draw an ellipse into the graphics of the bitmap (this being only the outline of the shape) using the pen created
Gdip_DrawEllipse(G, pPen, StartX, StartY, Diameter, Diameter)
; Delete the pen as it is no longer needed and wastes memory
Gdip_DeletePen(pPen)
; Create a slightly transparent (66) blue pen (ARGB = Transparency, red, green, blue) to draw a rectangle
; This pen is wider than the last one, with a thickness of 10
pPen := Gdip_CreatePen(0x660000ff, 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)
; 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)
Hotkey, LButton Up, Exit
}
Return
;#######################################################################
Exit:
; gdi+ may now be shutdown on exiting the program
Gdip_Shutdown(pToken)
Return
F3::Reload |
|
|
| Back to top |
|
 |
Razer
Joined: 15 Feb 2010 Posts: 10
|
Posted: Thu Mar 04, 2010 9:40 am Post subject: |
|
|
Hi Smurth,
Thx for your new version of the function Gdip_FillRoundedRectangle.
Can you also update the function Gdip_DrawRoundedRectangle with the same solution?
I'm using Gdip_FillRoundedRectangle to fill a rounded background and the Gdip_DrawRoundedRectangle to draw its border.
Razer. |
|
| 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
|