jk7800
Joined: 06 Jan 2008 Posts: 40 Location: Gdi+ v1.1
|
Posted: Wed Aug 20, 2008 12:16 pm Post subject: GdipDrawImagePointsI problem |
|
|
Lately I wanted to make a 3D animation, printing a result of the PrintWindow function in a polygon. So I started from loading an image to check if it works. But it doesn't . I used GdipDrawImagePointsI here and I believe that this is the problem, because with the GdipDrawImageRectI it works. What am I missing? I'm posting the code:
| Code: | #WinActivateForce
Gui, +LastFound -Caption +Owner +AlwaysOnTop +E0x80000
; -0x20 -E0x80 +Disable
AddImage("test.png",WinExist(),W,H)
Gui, Show, w200 h200, Experiment
AddImage(sFile,hGui,ByRef Width="",ByRef Height="",pBits="")
{
DllCall("SetLastError", UInt, 0)
If Not DllCall("GetModuleHandle", "str", "gdiplus")
DllCall("LoadLibrary" , "str", "gdiplus")
si := Chr(1)
DllCall("gdiplus\GdiplusStartup", "UintP", pToken, "Uint", &si, "Uint", 0)
VarSetCapacity(wFile, 1023)
DllCall("kernel32\MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sFile, "int", -1, "Uint", &wFile, "int", 512)
DllCall("gdiplus\GdipLoadImageFromFile", "Uint", &wFile, "UintP", pImage)
DllCall("gdiplus\GdipGetImageWidth", "Uint", pImage, "UintP", Width)
DllCall("gdiplus\GdipGetImageHeight", "Uint", pImage, "UintP", Height)
mDC := DllCall("gdi32\CreateCompatibleDC", "Uint", 0)
NumPut(VarSetCapacity(bi, 40, 0), bi)
NumPut(Width, bi, 4)
NumPut(Height, bi, 8)
NumPut(32, NumPut(1, bi, 12, "UShort"), 0, "Ushort")
mBM := DllCall("gdi32\CreateDIBSection", "Uint", mDC, "Uint", &bi, "Uint", DIB_RGB_COLORS:=0, "UintP", pBits, "Uint", 0, "Uint", 0)
oBM := DllCall("gdi32\SelectObject", "Uint", mDC, "Uint", mBM)
DllCall("gdiplus\GdipCreateFromHDC", "Uint", mDC, "UintP", pGraphics)
;DllCall("gdiplus\GdipDrawImageRectI", "Uint", pGraphics, "Uint", pImage, "int", 0, "int", 0, "int", Width, "int", Height)
VarSetCapacity(Rect, 16)
NumPut(0, Rect, 0, true)
NumPut(0, Rect, 4, true)
NumPut(200, Rect, 8, true)
NumPut(200, Rect, 12, true)
VarSetCapacity(Shape, 16)
NumPut(100, Shape, 0, true)
NumPut(0, Shape, 4, true)
NumPut(200, Shape, 8, true)
NumPut(200, Shape, 12, true)
COUNT:=1
msgbox % DllCall("gdiplus\GdipDrawImagePointsI", "Uint", pGraphics, UInt, pImage, UInt, &Rect, UInt, &Shape, UInt, COUNT)
DllCall("UpdateLayeredWindow", "Uint", hGui, "Uint", 0, "Uint", 0, "int64P", Width|Height<<32, "Uint", mDC, "int64P", 0, "Uint", 0, "intP",
0xFF<<16|1<<24, "Uint", 2)
DllCall("gdi32\SelectObject", "Uint", mDC, "Uint", oBM)
DllCall("gdi32\DeleteObject", "Uint", mBM)
DllCall("gdi32\DeleteDC", "Uint", hDC)
DllCall("gdiplus\GdipDeleteGraphics", "Uint", pGraphics)
DllCall("gdiplus\GdipDisposeImage", "Uint", pImage)
DllCall("gdiplus\GdiplusShutdown", "Uint", pToken)
If hModule := DllCall("GetModuleHandle", "str", "gdiplus")
DllCall("FreeLibrary" , "Uint", hModule)
} |
You'll need an image called test.png in the scripts directory. |
|