To simulate functions such as color searching and image searching, we must first familiarize ourselves with the relevant knowledge.
Our goal is to find the color and the image, so we only need to consider the 24 B color (pf24bit ).
The tcolor value is stored in hexadecimal format. The low Three Represent the saturation of red, green, and blue colors.
VaR
C: tcolor
R, G, B: byte;
Tcolor to RGB Value
R: = getrvalue (C );
G: = getgvalue (C );
B: = getbvalue (C );
Or
R: = C and $ ff;
G: = (C and $ ff00) SHR 8;
B: = (C and $ ff0000) SHR 16;
Convert RGB to tcolor
C: = strtoint (inttohex (B, 2) + inttohex (G, 2) + inttohex (R, 2 ));
Or
C: = RGB (R, G, B );
Quick access to BMP pixels. scanline is generally used.
Type // supplementary definition for ease of use
Prgbtriparray = ^ trgbtriplearray;
Trgbtriplearray = array [0 .. 1024-1] of trgbtriple;
VaR
Row: prgbtriparray;
P: trgbtriple;
Access column x (x, y) of row y)
Row: = BMP. scanline [y];
P: = row [x];
R: = P. rgbtred;
G: = P. rgbtgreen;
B: = P. rgbtblue;
Another access method
VaR
P: pbytearray;
Access column x (x, y) of row y)
P: = BMP .. scanline [y];
Use P [x * 3], p [x * 3 + 1], P [x * 3 + 2] for access