Tgpcolor is the color subject of gdiplus. Although it is a struct, methods and attributes are readily available like classes.
I don't think it is defined as a class or interface. I think it mainly needs to be implicitly converted with an integer, which requires operator overloading (currently only the structure is available ).
Multiple tgpcolor construction methods:
VaR C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11: tgpcolor; begin C1: = tgpcolor. create (0, 0,255); {opaque blue} C2: = tgpcolor. create (255, 0, 0,255); {opaque blue} C3: = tgpcolor. create (128, 0, 0,255); {translucent blue} C4: = tgpcolor. create ($ 800000ff); {translucent blue} C5: = tgpcolor. makeargb (128, 0, 0,255); {translucent blue} C6: = tgpcolor. createfromcolorref (clblue); {translucent blue, parameter is the color value in the traditional format of Delphi} c7.initialize (0, 0,255); {opaque blue} c8.initialize (128, 0, 0,255 ); {translucent blue} c9.initialize ($ 800000ff); {translucent blue} c10.initializefromcolorref (clblue); {opaque blue, the parameter is the color value in the traditional format of Delphi} C11: = tgpcolor. blue; {opaque blue, one of the 141 color constants in tgpcolor} end; // because tgpcolor uses Operator Overloading: tgpcolor can be implicitly converted to argb (Cardinal), so: var color: tgpcolor; begin color: = $ ff00ff00; showmessagefmt ('$ % x', [color. value]); // $ ff00ff00end; // vice versa: var num: argb; begin num: = tgpcolor. lime; showmessagefmt ('$ % x', [num]); // $ ff00ff00end;
Tgpcolor attributes:
VaR C: tgpcolor; begin C: = tgpcolor. create ($11, $22, $33, $44); {tgpcolor. value is the color value} showmessagefmt ('$ % x', [C. value]); // $11223344 {tgpcolor. colorref is the color value in the traditional format of Delphi} showmessagefmt ('$ % x', [C. colorref]); // $443322 {Alpha, red, green, and blue components} showmessagefmt ('$ %. 2x, $ %. 2x, $ %. 2x, $ %. 2x ', [C. a, c.r, C. g, c. B]); // $11, $22, $33, $44 {tgpcolor. alpha and tgpcolor. A is one thing} showmessagefmt ('$ %. 2x, $ %. 2x ', [C. alpha, C. a]); // $11, $ 11end;
Transparent color demonstrationCode:
Uses gdiplus, kernel; Procedure tform1.formpaint (Sender: tobject); var image: igpimage; brush: igpsolidbrush; rect: tgprect; begin chdir ('C: \ gdiplusimg \ '); image: = tgpimage.create('grapes.jpg '); canvas. togpgraphics. drawimage (image, 20, 10); rect. initialize (0, 20, image. width + 40, 35); brush: = tgpsolidbrush. create (tgpcolor. create (255, 0,128,255); canvas. togpgraphics. fillrectangle (brush, rect); rect. y: = rect. Y + rect. height + 20; brush: = tgpsolidbrush. create (tgpcolor. create (127, 0,128,255); canvas. togpgraphics. fillrectangle (brush, rect); rect. y: = rect. Y + rect. height + 20; brush: = tgpsolidbrush. create (tgpcolor. create (63, 0,128,255); canvas. togpgraphics. fillrectangle (brush, rect); end;
: