1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
const MaxPixelCount = 50001; //<à augmenter ou à diminuer selon besoins
type ppRGBArray = ^tTRGBArray;
tTRGBArray = ARRAY[0..MaxPixelCount-1] OF TRGBTriple;
var maCouleurCible : TColor;
function LisScanlinesVersMire(bmp : TBitMap; xc,yc : integer) : TMire;
// Nécessite que le Bmp soit au préalable déclaré Bmp.pixelFormat := pf24bit;
// xc,yc = coordonnées du point courant correspondant à la case centrale de la mire
var Ligne : ppRGBArray;
co,li,h,w : integer;
cl : TColor;
begin for co:=-1 to 1 do for li:=-1 to 1 do Result.M[co,li]:=0;
Result.S:=0;
with bmp do
begin h:=bmp.height; w:=bmp.width;
for li:=-1 to 1 do
begin if (yc+li>=0) and (yc+li<=h-1) then
begin Ligne := ScanLine[yc+li];
for co:=-1 to 1 do
begin if (xc+co>=0) and (xc+co<=w-1) then
begin with Ligne[xc+co] do
begin cl:=RGB(rgbtRed,rgbtGreen,rgbtBlue);
if cl=maCouleurCible then
begin Result.M[co,li]:=1;
inc(Result.S);
end;
end;
end; //if (xc
end; // for co
end; // if (yc
end; // for li
end; // with bmp
end; // LisScanlinesVersMire |
Partager