![]() |
|
|
#1
|
||||
|
||||
|
Есть цвет определённого пиксела на экране. Как мне относительно этого пиксела найти пикселы на экране у которых цвет не сильно отличается от данного, но разумеется оличается??????????
|
|
#2
|
||||
|
||||
|
1. Разложить цвет на R,G и B составляющие (shr, and).
2. Пробегаться по всем пикселам (лучше всего юзать Scanline). 3. Ставишь Код:
(abs(aR-bR)<10)and(abs(aG-bG)<10)and(abs(aB-bB)<10) 4. делаешь что хочешь. |
|
#3
|
||||
|
||||
|
А можно более чёткий пример пожалуйста!!!
|
|
#4
|
|||
|
|||
|
Код:
procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var i, j: Byte;
aR, aG, aB: Byte;
bR, bG, bB: Byte;
NeSilOtlich:Byte;
x1,x2,y1,y2:integer;
begin
Image2.Picture:=nil;
NeSilOtlich:=15;
aR:=GetRValue(Image1.Canvas.Pixels[x,y]);
aG:=GetGValue(Image1.Canvas.Pixels[x,y]);
aB:=GetBValue(Image1.Canvas.Pixels[x,y]);
x1:=1;
y1:=1;
x2:=x1+8;
y2:=8;
for i:=1 to Image1.Width do
for j:=1 to Image1.Height do
begin
bR:=GetRValue(Image1.Canvas.Pixels[i,j]);
bG:=GetGValue(Image1.Canvas.Pixels[i,j]);
bB:=GetBValue(Image1.Canvas.Pixels[i,j]);
if (abs(aR-bR)<NeSilOtlich)and(abs(aG-bG)<NeSilOtlich)and(abs(aB-bB)<NeSilOtlich) then
begin
Image2.Canvas.Brush.Color:=RGB(bR,bG,bB);
Image2.Canvas.Rectangle(x1,y1,x2,y2);
if x1+50<image2.Width then x1:=x1+8 else
Begin x1:=1; y1:=y1+8; y2:=y2+8; end;
x2:=x1+8;
end;
end;
end; |