I've been trying to implement a call to the MSIMG32.DLL function GradientFill. Anyway, I have not been able to accomplish that yet, since TRIVERTEX arrays must be created.

Can anybody help me with that? I can deliver the source in Pascal if needed.

TiA
Posted on 2002-03-09 07:18:52 by Donnerwolf
http://www.asmcommunity.net/board/index.php?topic=3486

Sorry, can't help you. But if you post the Pascal Source, I'm sure somebody can help ya!
Posted on 2002-03-09 10:26:38 by bazik
define the structures:
TRIVERTEX struct

x dword ?
y dword ?
Red word ?
Green word ?
Blue word ?
Alpha word ?
TRIVERTEX ends

GRADIENT_RECT struct
UpperLeft dword ?
LowerRight dword ?
GRADIENT_RECT ends

The constants needed:
GRADIENT_FILL_RECT_H	equ 0

GRADIENT_FILL_RECT_V equ 1

Your structures. Color2 must be right after Color1
Color1       TRIVERTEX <>

Color2 TRIVERTEX <>
Grad_Rect GRADIENT_RECT <>

Fill the TRIVERTEX struct with your favorite color:
mov       eax, MyColor

mov edx, offset Color1
assume edx:ptr TRIVERTEX
shl eax, 8
mov [edx].Red, ax
shr eax, 16
shl eax, 8
mov [edx].Green, ax
shr eax, 16
shl eax, 8
mov [edx].Blue, ax
mov [edx].Alpha, 0
push X ;X coord
pop [edx].x
push Y ;Y coord
pop [edx].y
assume edx:NOTHING

Repeat for Color2
X and Y will be coords of upper-left rectangle corner for the 1st color,
and of bottom-right corner for the 2nd color.
Then, call the API:
mov     Grad_Rect.UpperLeft, 0

mov Grad_Rect.LowerRight, 1
invoke GradientFill, hdc, offset Color1, 2, offset Grad_Rect, 1, GRADIENT_FILL_RECT_H
Posted on 2002-03-09 12:32:50 by micmic
(the technique is similar for triangles)
Posted on 2002-03-09 12:33:06 by micmic
It's very interesting but I can't get it run properly with triangle fill. And except all I cant find out the help file with description of this function. So, my program works with horisontal or vertical fill, not with triangle. Why?

Regards, Mike
PS See code in attach file
Posted on 2002-03-10 04:43:42 by Mike
Documentation is online at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_8oa4.asp

For triangles you need a GRADIENT_TRIANGLE struct and at least 3 colors. Here is the example:
Posted on 2002-03-10 12:57:27 by micmic