AutoHotkey Community

It is currently May 27th, 2012, 1:21 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: August 20th, 2008, 1:16 pm 
Offline

Joined: January 6th, 2008, 8:09 pm
Posts: 39
Location: Gdi+ v1.1
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 :cry: . 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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 20th, 2008, 4:21 pm 
Offline

Joined: April 9th, 2007, 4:43 pm
Posts: 172
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.

_________________
COMPLETELY INACTIVE - I do not use AHK anymore.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, chaosad, oldbrother and 18 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group