AutoHotkey Community

It is currently May 26th, 2012, 2:56 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 93 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7
Author Message
 Post subject:
PostPosted: January 28th, 2009, 11:06 pm 
Oh.,yes, I tested it. bit shifting takes almost half the time.
You are right, I will stop complaining.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 1st, 2009, 10:48 pm 
Offline

Joined: February 26th, 2006, 9:45 am
Posts: 55
Location: Recife Brazil
Quote:
Now that I think about it, you could probably even do it with GDI or GDI+, without 3D hardware.

I did it in VB with the msimg32.dll ( http://msdn.microsoft.com/en-us/library/dd144957 ) and it works super fast, really promissing, but after hours of trying I still can´t make it work with AHK.
Code:
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 Sub

I 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?
Code:
#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" , &gt, "UInt", 2, "UInt", 0x2)
if errorlevel
msgbox %errorlevel%

Gui, Show, w270 h270


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2009, 10:15 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
For an example, see [Function] _CreateImageButton_ (Colored buttons with GDI).


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 93 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 4 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