Oh.,yes, I tested it. bit shifting takes almost half the time.
You are right, I will stop complaining.

Opinions wanted : Optimized DllCall()
Started by
Pil
, Aug 13 2008 09:13 PM
92 replies to this topic
#91
-
Posted 28 January 2009 - 10:06 PM

I did it in VB with the msimg32.dll ( <!-- m -->http://msdn.microsof...ibrary/dd144957<!-- m --> ) and it works super fast, really promissing, but after hours of trying I still can“t make it work with AHK.Now that I think about it, you could probably even do it with GDI or GDI+, without 3D hardware.
Option Explicit Private Type GRADIENT_TRIANGLE Vertex1 As Long Vertex2 As Long Vertex3 As Long End Type Private Type TRIVERTEX X As Long Y As Long Red As Integer Green As Integer Blue As Integer Alpha As Integer End Type Const GRADIENT_FILL_TRIANGLE As Long = &H2 Private Declare Function GradientFillTriangle Lib "msimg32" Alias "GradientFill" (ByVal hDC As Long, pVertex As TRIVERTEX, ByVal dwNumVertex As Long, pMesh As GRADIENT_TRIANGLE, ByVal dwNumMesh As Long, ByVal dwMode As Long) As Long Private Sub Form_Load() Dim trVert(4) As TRIVERTEX Dim gTr(1) As GRADIENT_TRIANGLE ScaleMode = vbPixels AutoRedraw = True Move Left, Top, 3945, 4230 trVert(0).X = 0 trVert(0).Y = 0 trVert(0).Red = 0& trVert(0).Green = -256 trVert(0).Blue = 0& trVert(0).Alpha = 0& trVert(1).X = 255 trVert(1).Y = 0 trVert(1).Red = -256 trVert(1).Green = -256 trVert(1).Blue = 0& trVert(1).Alpha = 0& trVert(2).X = 256 trVert(2).Y = 256 trVert(2).Red = -256 trVert(2).Green = 0& trVert(2).Blue = 0& trVert(2).Alpha = 0& trVert(3).X = 0 trVert(3).Y = 256 trVert(3).Red = 0& trVert(3).Green = 0& trVert(3).Blue = 0& trVert(3).Alpha = 0& gTr(0).Vertex1 = 0 gTr(0).Vertex2 = 1 gTr(0).Vertex3 = 2 gTr(1).Vertex1 = 0 gTr(1).Vertex2 = 2 gTr(1).Vertex3 = 3 GradientFillTriangle hDC, trVert(0), 4, gTr(0), 2, GRADIENT_FILL_TRIANGLE Form1.Show End SubI assume that array fields of GRADIENT_TRIANGLE type and TRIVERTEX stucture are in memory as a chain one after other.
What am I doing wrong?
#NoEnv Gui, +ToolWindow +LastFound hDC:=DllCall("GetDC",UInt,Gui) VarSetCapacity(24,gt,0) NumPut(0,gt,0, "UInt") NumPut(1,gt,4, "UInt") NumPut(2,gt,8, "UInt") NumPut(0,gt,12, "UInt") NumPut(2,gt,16, "UInt") NumPut(3,gt,20, "UInt") VarSetCapacity(64,tv,0) NumPut(0,tv,0, "UInt") NumPut(0,tv,4, "UInt") NumPut(0,tv,8, "UShort") NumPut(-256,tv,10, "UShort") NumPut(0,tv,12, "UShort") NumPut(0,tv,14, "UShort") NumPut(255,tv,16, "UInt") NumPut(0,tv,20, "UInt") NumPut(-256,tv,24, "UShort") NumPut(-256,tv,26, "UShort") NumPut(0,tv,28, "UShort") NumPut(0,tv,30, "UShort") NumPut(256,tv,32, "UInt") NumPut(256,tv,36, "UInt") NumPut(-256,tv,40, "UShort") NumPut(0,tv,42, "UShort") NumPut(0,tv,44, "UShort") NumPut(0,tv,46, "UShort") NumPut(0,tv,48, "UInt") NumPut(256,tv,52, "UInt") NumPut(0,tv,56, "UShort") NumPut(0,tv,58, "UShort") NumPut(0,tv,60, "UShort") NumPut(0,tv,62, "UShort") DllCall("msimg32.dll\GradientFill", "UInt", hDC,"UInt" , &tv, "UInt", 4, "UInt" , >, "UInt", 2, "UInt", 0x2) if errorlevel msgbox %errorlevel% Gui, Show, w270 h270
#92
-
Posted 01 February 2009 - 09:48 PM

For an example, see [Function] _CreateImageButton_ (Colored buttons with GDI).
#93
-
Posted 02 February 2009 - 09:15 AM
