 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Wicked
Joined: 07 Jun 2008 Posts: 369
|
Posted: Sat Jul 10, 2010 2:47 pm Post subject: |
|
|
| fragman wrote: | | One more thing, the Gdip_BitmapFromHWND produces artefacts such as black title bars(chrome) or black navigation bar (explorer) on my system (Windows 7 32bit). Any known workaround? |
I'm not sure if I know exactly what you mean, but maybe 1 of 2 things.
Use SysGet to find the height if the title bars, etc, if they even exist.
Check the window style of the window to make sure that the title bar isn't hidden.
Sorry if I'm misunderstanding you. |
|
| Back to top |
|
 |
fragman
Joined: 13 Oct 2009 Posts: 1199
|
Posted: Sat Jul 10, 2010 2:52 pm Post subject: |
|
|
Let me show you a screenshot: Image.
This is what it looks like when taken with gdip. Using Alt+PrintScreen I get this: Image
Could this be because of transparency with black background? If yes, how to set it to white? |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Jul 15, 2010 4:46 am Post subject: |
|
|
I'm probably doing something wrong here, but I'm new to AHK. I'm trying to use Gdip.ahk and the ConvertImage or convert_resize scripts I've found on here to resize an image. However, when I include gdip.ahk I get an error message.
| Code: |
Error at line 383 in #include file
"…gdip.ahk".
Line Text: CreateDIBSection(w, h, hdc="", bpp=32, ByRef ppvBits=0)
Error: Duplicate function definition.
The program will exit.
|
I'm also using a file I got from here, I named the file ScreenCapture,ahk, I don't remember if that was the original name or not. I put a copy below. I'm guessing it is something in this file that is causing the issue, but I'm not sure.
| Code: |
/* CaptureScreen(aRect, bCursor, sFileTo, nQuality)
1) If the optional parameter bCursor is True, captures the cursor too.
2) If the optional parameter sFileTo is 0, set the image to Clipboard.
If it is omitted or "", saves to screen.bmp in the script folder,
otherwise to sFileTo which can be BMP/JPG/PNG/GIF/TIF.
3) The optional parameter nQuality is applicable only when sFileTo is JPG. Set it to the desired quality level of the resulting JPG, an integer between 0 - 100.
4) If aRect is 0/1/2/3, captures the entire desktop/active window/active client area/active monitor.
5) aRect can be comma delimited sequence of coordinates, e.g., "Left, Top, Right, Bottom" or "Left, Top, Right, Bottom, Width_Zoomed, Height_Zoomed".
In this case, only that portion of the rectangle will be captured. Additionally, in the latter case, zoomed to the new width/height, Width_Zoomed/Height_Zoomed.
Example:
CaptureScreen(0)
CaptureScreen(1)
CaptureScreen(2)
CaptureScreen(3)
CaptureScreen("100, 100, 200, 200")
CaptureScreen("100, 100, 200, 200, 400, 400") ; Zoomed
*/
/* Convert(sFileFr, sFileTo, nQuality)
Convert("C:\image.bmp", "C:\image.jpg")
Convert("C:\image.bmp", "C:\image.jpg", 95)
Convert(0, "C:\clip.png") ; Save the bitmap in the clipboard to sFileTo if sFileFr is "" or 0.
*/
;CaptureScreen()
;Return
CaptureScreen(aRect = 0, bCursor = False, sFile = "", nQuality = "")
{
If !aRect
{
SysGet, nL, 76
SysGet, nT, 77
SysGet, nW, 78
SysGet, nH, 79
}
Else If aRect = 1
WinGetPos, nL, nT, nW, nH, A
Else If aRect = 2
{
WinGet, hWnd, ID, A
VarSetCapacity(rt, 16, 0)
DllCall("GetClientRect" , "Uint", hWnd, "Uint", &rt)
DllCall("ClientToScreen", "Uint", hWnd, "Uint", &rt)
nL := NumGet(rt, 0, "int")
nT := NumGet(rt, 4, "int")
nW := NumGet(rt, 8)
nH := NumGet(rt,12)
}
Else If aRect = 3
{
VarSetCapacity(mi, 40, 0)
DllCall("GetCursorPos", "int64P", pt)
DllCall("GetMonitorInfo", "Uint", DllCall("MonitorFromPoint", "int64", pt, "Uint", 2), "Uint", NumPut(40,mi)-4)
nL := NumGet(mi, 4, "int")
nT := NumGet(mi, 8, "int")
nW := NumGet(mi,12, "int") - nL
nH := NumGet(mi,16, "int") - nT
}
Else
{
StringSplit, rt, aRect, `,, %A_Space%%A_Tab%
nL := rt1
nT := rt2
nW := rt3 - rt1
nH := rt4 - rt2
znW := rt5
znH := rt6
}
mDC := DllCall("CreateCompatibleDC", "Uint", 0)
hBM := CreateDIBSection(mDC, nW, nH)
oBM := DllCall("SelectObject", "Uint", mDC, "Uint", hBM)
hDC := DllCall("GetDC", "Uint", 0)
DllCall("BitBlt", "Uint", mDC, "int", 0, "int", 0, "int", nW, "int", nH, "Uint", hDC, "int", nL, "int", nT, "Uint", 0x40000000 | 0x00CC0020)
DllCall("ReleaseDC", "Uint", 0, "Uint", hDC)
If bCursor
CaptureCursor(mDC, nL, nT)
DllCall("SelectObject", "Uint", mDC, "Uint", oBM)
DllCall("DeleteDC", "Uint", mDC)
If znW && znH
hBM := Zoomer(hBM, nW, nH, znW, znH)
If sFile = 0
SetClipboardData(hBM)
Else Convert(hBM, sFile, nQuality), DllCall("DeleteObject", "Uint", hBM)
}
CaptureCursor(hDC, nL, nT)
{
VarSetCapacity(mi, 20, 0)
mi := Chr(20)
DllCall("GetCursorInfo", "Uint", &mi)
bShow := NumGet(mi, 4)
hCursor := NumGet(mi, 8)
xCursor := NumGet(mi,12)
yCursor := NumGet(mi,16)
VarSetCapacity(ni, 20, 0)
DllCall("GetIconInfo", "Uint", hCursor, "Uint", &ni)
xHotspot := NumGet(ni, 4)
yHotspot := NumGet(ni, 8)
hBMMask := NumGet(ni,12)
hBMColor := NumGet(ni,16)
If bShow
DllCall("DrawIcon", "Uint", hDC, "int", xCursor - xHotspot - nL, "int", yCursor - yHotspot - nT, "Uint", hCursor)
If hBMMask
DllCall("DeleteObject", "Uint", hBMMask)
If hBMColor
DllCall("DeleteObject", "Uint", hBMColor)
}
Zoomer(hBM, nW, nH, znW, znH)
{
mDC1 := DllCall("CreateCompatibleDC", "Uint", 0)
mDC2 := DllCall("CreateCompatibleDC", "Uint", 0)
zhBM := CreateDIBSection(mDC2, znW, znH)
oBM1 := DllCall("SelectObject", "Uint", mDC1, "Uint", hBM)
oBM2 := DllCall("SelectObject", "Uint", mDC2, "Uint", zhBM)
DllCall("SetStretchBltMode", "Uint", mDC2, "int", 4)
DllCall("StretchBlt", "Uint", mDC2, "int", 0, "int", 0, "int", znW, "int", znH, "Uint", mDC1, "int", 0, "int", 0, "int", nW, "int", nH, "Uint", 0x00CC0020)
DllCall("SelectObject", "Uint", mDC1, "Uint", oBM1)
DllCall("SelectObject", "Uint", mDC2, "Uint", oBM2)
DllCall("DeleteDC", "Uint", mDC1)
DllCall("DeleteDC", "Uint", mDC2)
DllCall("DeleteObject", "Uint", hBM)
Return zhBM
}
Convert(sFileFr = "", sFileTo = "", nQuality = "")
{
If sFileTo =
sFileTo := A_ScriptDir . "\screen.bmp"
SplitPath, sFileTo, , sDirTo, sExtTo, sNameTo
If Not hGdiPlus := DllCall("LoadLibrary", "str", "gdiplus.dll")
Return sFileFr+0 ? SaveHBITMAPToFile(sFileFr, sDirTo . "\" . sNameTo . ".bmp") : ""
VarSetCapacity(si, 16, 0), si := Chr(1)
DllCall("gdiplus\GdiplusStartup", "UintP", pToken, "Uint", &si, "Uint", 0)
If !sFileFr
{
DllCall("OpenClipboard", "Uint", 0)
If DllCall("IsClipboardFormatAvailable", "Uint", 2) && (hBM:=DllCall("GetClipboardData", "Uint", 2))
DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "Uint", hBM, "Uint", 0, "UintP", pImage)
DllCall("CloseClipboard")
}
Else If sFileFr Is Integer
DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "Uint", sFileFr, "Uint", 0, "UintP", pImage)
Else DllCall("gdiplus\GdipLoadImageFromFile", "Uint", Unicode4Ansi(wFileFr,sFileFr), "UintP", pImage)
DllCall("gdiplus\GdipGetImageEncodersSize", "UintP", nCount, "UintP", nSize)
VarSetCapacity(ci,nSize,0)
DllCall("gdiplus\GdipGetImageEncoders", "Uint", nCount, "Uint", nSize, "Uint", &ci)
Loop, % nCount
If InStr(Ansi4Unicode(NumGet(ci,76*(A_Index-1)+44)), "." . sExtTo)
{
pCodec := &ci+76*(A_Index-1)
Break
}
If InStr(".JPG.JPEG.JPE.JFIF", "." . sExtTo) && nQuality<>"" && pImage && pCodec
{
DllCall("gdiplus\GdipGetEncoderParameterListSize", "Uint", pImage, "Uint", pCodec, "UintP", nSize)
VarSetCapacity(pi,nSize,0)
DllCall("gdiplus\GdipGetEncoderParameterList", "Uint", pImage, "Uint", pCodec, "Uint", nSize, "Uint", &pi)
Loop, % NumGet(pi)
If NumGet(pi,28*(A_Index-1)+20)=1 && NumGet(pi,28*(A_Index-1)+24)=6
{
pParam := &pi+28*(A_Index-1)
NumPut(nQuality,NumGet(NumPut(4,NumPut(1,pParam+0)+20)))
Break
}
}
If pImage
pCodec ? DllCall("gdiplus\GdipSaveImageToFile", "Uint", pImage, "Uint", Unicode4Ansi(wFileTo,sFileTo), "Uint", pCodec, "Uint", pParam) : DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "Uint", pImage, "UintP", hBitmap, "Uint", 0) . SetClipboardData(hBitmap), DllCall("gdiplus\GdipDisposeImage", "Uint", pImage)
DllCall("gdiplus\GdiplusShutdown" , "Uint", pToken)
DllCall("FreeLibrary", "Uint", hGdiPlus)
}
CreateDIBSection(hDC, nW, nH, bpp = 32, ByRef pBits = "")
{
NumPut(VarSetCapacity(bi, 40, 0), bi)
NumPut(nW, bi, 4)
NumPut(nH, bi, 8)
NumPut(bpp, NumPut(1, bi, 12, "UShort"), 0, "Ushort")
NumPut(0, bi,16)
Return DllCall("gdi32\CreateDIBSection", "Uint", hDC, "Uint", &bi, "Uint", 0, "UintP", pBits, "Uint", 0, "Uint", 0)
}
SaveHBITMAPToFile(hBitmap, sFile)
{
DllCall("GetObject", "Uint", hBitmap, "int", VarSetCapacity(oi,84,0), "Uint", &oi)
hFile:= DllCall("CreateFile", "Uint", &sFile, "Uint", 0x40000000, "Uint", 0, "Uint", 0, "Uint", 2, "Uint", 0, "Uint", 0)
DllCall("WriteFile", "Uint", hFile, "int64P", 0x4D42|14+40+NumGet(oi,44)<<16, "Uint", 6, "UintP", 0, "Uint", 0)
DllCall("WriteFile", "Uint", hFile, "int64P", 54<<32, "Uint", 8, "UintP", 0, "Uint", 0)
DllCall("WriteFile", "Uint", hFile, "Uint", &oi+24, "Uint", 40, "UintP", 0, "Uint", 0)
DllCall("WriteFile", "Uint", hFile, "Uint", NumGet(oi,20), "Uint", NumGet(oi,44), "UintP", 0, "Uint", 0)
DllCall("CloseHandle", "Uint", hFile)
}
SetClipboardData(hBitmap)
{
DllCall("GetObject", "Uint", hBitmap, "int", VarSetCapacity(oi,84,0), "Uint", &oi)
hDIB := DllCall("GlobalAlloc", "Uint", 2, "Uint", 40+NumGet(oi,44))
pDIB := DllCall("GlobalLock", "Uint", hDIB)
DllCall("RtlMoveMemory", "Uint", pDIB, "Uint", &oi+24, "Uint", 40)
DllCall("RtlMoveMemory", "Uint", pDIB+40, "Uint", NumGet(oi,20), "Uint", NumGet(oi,44))
DllCall("GlobalUnlock", "Uint", hDIB)
DllCall("DeleteObject", "Uint", hBitmap)
DllCall("OpenClipboard", "Uint", 0)
DllCall("EmptyClipboard")
DllCall("SetClipboardData", "Uint", 8, "Uint", hDIB)
DllCall("CloseClipboard")
}
Unicode4Ansi(ByRef wString, sString)
{
nSize := DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", 0, "int", 0)
VarSetCapacity(wString, nSize * 2)
DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", &wString, "int", nSize)
Return &wString
}
Ansi4Unicode(pString)
{
nSize := DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "Uint", 0, "int", 0, "Uint", 0, "Uint", 0)
VarSetCapacity(sString, nSize)
DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "str", sString, "int", nSize, "Uint", 0, "Uint", 0)
Return sString
}
|
Thanks for the help. If a resize parameter or function could be added to the CaptureScreen function that would work too. I'm fairly certain the ability is there, but it is a bit over my head at the moment. |
|
| Back to top |
|
 |
tomf80
Joined: 15 Jul 2010 Posts: 10
|
Posted: Thu Jul 15, 2010 4:48 am Post subject: |
|
|
Sorry, I forgot to sign in with that post. Just replying again so hopefully I can get notifications of replies. Thanks again for the help!
EDIT: I figured out a way to do it and modified the ScreenCapture file.
I would delete the previous post, but I don't think you can if it was posted as a guest, I'm sorry. |
|
| Back to top |
|
 |
zhuluobin
Joined: 11 May 2009 Posts: 28
|
Posted: Thu Jul 15, 2010 6:09 am Post subject: |
|
|
Is there any way to add a shadow to graphics drawed on screen?
I found some examples in which authors simply used UpdateLayeredWindow to add shadow to a png image, like this
but i failed on this, png has been drawed on screen but there is no shadow at all. Neither dllcall nor gdip.ahk |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1786
|
Posted: Thu Jul 15, 2010 9:14 am Post subject: |
|
|
tomf80
You could replace all of those functions with the equivalent gdi+ functions fom the library. Gdip_BitmapFromScreen will pretty much already do that
zhuluobin
Are you meaning you wish to write text with a shadow, or a png that you have already, youd like to add a shadow? If the latter, then give an example png
Also, library updated to 1.36. Fix spotted by fragman to enable Cleartype enumeration in Gdip_TextToGraphics
Yeh fragman, the black will be because of the transparencies. More tests will need to be done for an alternative solution, but it wont be possible to capture those transparencies using PrintWindow. A temporary fix would be using Lockbits and looping |
|
| Back to top |
|
 |
zhuluobin
Joined: 11 May 2009 Posts: 28
|
Posted: Thu Jul 15, 2010 9:38 am Post subject: |
|
|
tic
Yes, i want to draw a png to screen and give it a shadow.
If possible, i'd like to give other graphic( drawed by brush or pen) a shadow
how can i fulfil it?
And here is a png without shadow
 |
|
| Back to top |
|
 |
Learning one
Joined: 04 Apr 2009 Posts: 1001 Location: Croatia
|
Posted: Thu Jul 15, 2010 3:37 pm Post subject: |
|
|
| Just tested Cleartype in Gdip_TextToGraphics. Very useful for small text. |
|
| Back to top |
|
 |
Wicked
Joined: 07 Jun 2008 Posts: 369
|
Posted: Thu Jul 15, 2010 4:25 pm Post subject: |
|
|
| zhuluobin wrote: | tic
Yes, i want to draw a png to screen and give it a shadow.
If possible, i'd like to give other graphic( drawed by brush or pen) a shadow
how can i fulfil it?
And here is a png without shadow
|
Convert it to grayscale, add a blur, move it down a few pixels. .
Well, that'd be the lazy man's way. . |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1786
|
Posted: Thu Jul 15, 2010 4:42 pm Post subject: |
|
|
Modified tutorial 3.....
Please redownload the library to 1.37 as I noticed a small error where Gdip_BlurBitmap would dispose of the image it was passed, which is not what I intended it to do
| Code: | ; gdi+ ahk tutorial 3 written by tic (Tariq Porter)
; Requires Gdip.ahk either in your Lib folder as standard library or using #Include
;
; Tutorial to take make a gui from an existing image on disk
; For the example we will use png as it can handle transparencies. The image will also be halved in size
#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
Blur := 15
Size := 0.02
; 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 +OwnDialogs +Owner +AlwaysOnTop
; Show the window
Gui, 1: Show, NA
; Get a handle to this window we have created in order to update it later
hwnd1 := WinExist()
; If the image we want to work with does not exist on disk, then download it...
If !FileExist("Main_OS_002.png")
UrlDownloadToFile, http://d.lanrentuku.com/down/png/0904/3d_os/Main_OS_002.png, Main_OS_002.png
; Get a bitmap from the image
pBitmap := Gdip_CreateBitmapFromFile("Main_OS_002.png")
; Check to ensure we actually got a bitmap from the file, in case the file was corrupt or some other error occured
If !pBitmap
{
MsgBox, 48, File loading error!, Could not load the image specified
ExitApp
}
; Get the width and height of the bitmap we have just created from the file
; This will be the dimensions that the file is
Width := Gdip_GetImageWidth(pBitmap), Height := Gdip_GetImageHeight(pBitmap)
; 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
; We are creating this "canvas" at half the size of the actual image
; We are halving it because we want the image to show in a gui on the screen at half its dimensions
hbm := CreateDIBSection(Width//2+(Width*Size), Height//2+(Height*Size))
; 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)
; We do not need SmoothingMode as we did in previous examples for drawing an image
; Instead we must set InterpolationMode. This specifies how a file will be resized (the quality of the resize)
; Interpolation mode has been set to HighQualityBicubic = 7
Gdip_SetInterpolationMode(G, 7)
Matrix = 0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0.7|0|0|0|0|0|1
pBitmapBlur := Gdip_BlurBitmap(pBitmap, Blur)
Gdip_DrawImage(G, pBitmapBlur, Width*Size, Height*Size, Width//2, Height//2, 0, 0, Width, Height, Matrix)
Gdip_DisposeImage(pBitmapBlur)
; DrawImage will draw the bitmap we took from the file into the graphics of the bitmap we created
; We are wanting to draw the entire image, but at half its size
; Coordinates are therefore taken from (0,0) of the source bitmap and also into the destination bitmap
; The source height and width are specified, and also the destination width and height (half the original)
; Gdip_DrawImage(pGraphics, pBitmap, dx, dy, dw, dh, sx, sy, sw, sh, Matrix)
; d is for destination and s is for source. We will not talk about the matrix yet (this is for changing colours when drawing)
Gdip_DrawImage(G, pBitmap, 0, 0, Width//2, Height//2, 0, 0, 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
; So this will position our gui at (0,0) with the Width and Height specified earlier (half of the original image)
UpdateLayeredWindow(hwnd1, hdc
, ((A_ScreenWidth-Width//2)//2)+(Width*Size), ((A_ScreenHeight-Height//2)+(Height*Size))//2
, Width//2+(Width*Size), Height//2+(Height*Size))
; 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)
; The bitmap we made from the image may be deleted
Gdip_DisposeImage(pBitmap)
Return
;#######################################################################
Exit:
; gdi+ may now be shutdown on exiting the program
Gdip_Shutdown(pToken)
ExitApp
Return |
|
|
| Back to top |
|
 |
Wicked
Joined: 07 Jun 2008 Posts: 369
|
Posted: Thu Jul 15, 2010 10:01 pm Post subject: |
|
|
| Kudo, tic. Thank you for the example. =) |
|
| Back to top |
|
 |
zhuluobin
Joined: 11 May 2009 Posts: 28
|
Posted: Thu Jul 15, 2010 11:54 pm Post subject: |
|
|
Thank you tic and Wicked
I did the same way, as the problem about blurbitmap you pointed out, I created 2 bitmaps, one of them for shadow( at that time i didn't know how to set blured graphic grey, now I got it and updated gdip.ahk to 1.37) |
|
| Back to top |
|
 |
zhuluobin
Joined: 11 May 2009 Posts: 28
|
Posted: Sat Jul 17, 2010 1:46 am Post subject: |
|
|
Graphics drawed by brush can not be blured, so i just used pen to draw fading frame around it, which made a shadow.
This is an example giving shadow for graphics in Tutorial 1.
I'm still trying to make it better, so the code is ugly.
| Code: |
#SingleInstance, Force
#NoEnv
SetBatchLines, -1
If !pToken := Gdip_Startup()
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
ExitApp
}
OnExit, Exit
Width := 600, Height := 400
Gui, 1: -Caption +E0x80000 +LastFound +OwnDialogs +Owner +AlwaysOnTop
Gui, 1: Show, NA
hwnd1 := WinExist()
hbm := CreateDIBSection(Width, Height)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetSmoothingMode(G, 4)
SetFormat,integer,hex
trans:=0x88
thick:=1
x:=102
y:=52
w:=200
h:=300
Loop,5
{
set := trans . "303030"
pPen := Gdip_CreatePen(set, A_Index*3)
Gdip_DrawEllipse(G, pPen, x, y, w, h)
trans := trans-25
}
pBrush := Gdip_BrushCreateSolid(0xff303030)
Gdip_FillEllipse(G, pBrush, x, y, 200, 300)
pBrush := Gdip_BrushCreateSolid(0xffff0000)
Gdip_FillEllipse(G, pBrush, 100, 50, 200, 300)
x:=258
y:=88
w:=296
h:=196
trans:=0x88
Loop,5
{
set := trans . "303030"
pPen := Gdip_CreatePen(set, A_Index*2)
Gdip_DrawRectangle(G, pPen, x, y, w, h)
trans := trans-25
}
SetFormat,integer,d
pBrush := Gdip_BrushCreateSolid(0xff303030)
Gdip_FillRectangle(G, pBrush, x, y, w, h)
pBrush := Gdip_BrushCreateSolid(0xcc8822cc)
Gdip_FillRectangle(G, pBrush, 250, 80, 300, 200)
Gdip_DeleteBrush(pBrush)
UpdateLayeredWindow(hwnd1, hdc, 0, 0, Width, Height)
SelectObject(hdc, obm)
DeleteObject(hbm)
DeleteDC(hdc)
Gdip_DeleteGraphics(G)
Return
;#######################################################################
Exit:
Gdip_Shutdown(pToken)
ExitApp
Return |
|
|
| Back to top |
|
 |
Carcophan
Joined: 24 Dec 2008 Posts: 1308 Location: :noitacoL
|
Posted: Tue Aug 03, 2010 4:22 pm Post subject: |
|
|
I have been looking around for a solution, and was hoping someone could point me in the right direction. I have spent a lot of time getting a graph to work as needed, but now I need to insert the graph into a GUI.
From some reading, it looks like I may need to save my GDI graph as a bmp image, and then open the bmp file in the gui itself.
I was wondering if there was a way to, as a variable or something, simply insert my little graph on top of a gui? I have to assume that I will not be able to write to the local computer and I didn't want to add unneeded steps if they could be avoided.
I have tried to reverse engineer the 9th tutorial and several other things, but it seems that I am missing something small to get this working correctly. Normally, I get either the GUI or the image itself to appear, and never both at once (let alone the graph inserted into the gui)
The example of the graph itself can be found at the bottom of this post >here< . My end result is to insert this image in a smaller GUI, and allow horizontal and vertical scrolling of the image pane on the gui.... but I cant even get it to insert into a gui correctly.  |
|
| Back to top |
|
 |
Lucid_Method
Joined: 19 Apr 2010 Posts: 145 Location: Mobile, AL
|
Posted: Tue Aug 03, 2010 9:25 pm Post subject: |
|
|
Tic, GDip is amazing! Thanks for everything you've posted.. your examples are great.
I know this question has been asked a number of times (without an easy solution that I could understand), I was hoping maybe advances in GDip may have made it possible by now..
I'm looking for a way to do an image-search on a non-visible BMP file, either by opening in the background and searching or preferably by just reading in the image to search --- to search an image for a small image instead of having to search the visible desktop.
Something along the lines of :
ImageSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, SmallSearchImage, FullDesktopImage
I just took one of the examples using Gdip_BitmapFromHWND(hNotepad) and took a full screen shot of a window that was completely covered - there HAS to be some way to search an image file without being visible.
Any ideas? |
|
| 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
|