AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GdipDrawImagePointsI problem

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
jk7800



Joined: 06 Jan 2008
Posts: 40
Location: Gdi+ v1.1

PostPosted: Wed Aug 20, 2008 12:16 pm    Post subject: GdipDrawImagePointsI problem Reply with quote

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 Crying or Very sad . 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.
Back to top
View user's profile Send private message
John W



Joined: 09 Apr 2007
Posts: 172

PostPosted: Wed Aug 20, 2008 3:21 pm    Post subject: Reply with quote

For this surpose I would say: Use another language like Python.
Image editing in this way is very hard in ahk, while Python offers libs which are easier to use.
_________________
John
Inactive - Until AutoHotkey is available for Linux.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group