怎么抠掉一幅图片当中的某种或几种颜色?(50分)

W

wcwcw

Unregistered / Unconfirmed
GUEST, unregistred user!
怎么抠掉一幅图片当中的某种或几种颜色?
 
用TCanvas对象的FloodFill方法。
 

image1.Picture.Bitmap.TransparentColor := clWhite; //去掉的颜色
image1.Transparent := true;
 
谢谢二位!
我的意思是 某一点的颜色RGB(12, 23, 34), 如何把这点的红色抠掉!
 
procedure TForm1.Button1Click(Sender: TObject);
// 将一副图片反色
var
x,y : Integer;
BitMap : TBitMap;
P : PByteArray;
begin
BitMap := TBitMap.create;
try
BitMap.LoadFromFile('Light.bmp');
for y := 0 to BitMap.Height -1 do
begin
P := BitMap.ScanLine[y];
for x := 0 to BitMap.Width -1 do
P[x] := 255-P[x];
//if P[x] = clWhite then P[X] := clRed;
end;
Canvas.Draw(0,0,BitMap);
finally
BitMap.Free;
end;
end;
 
思路如下
RGB的值是LONGINT形式的
前8为是红紧跟着的是GREEN和BLUE
如下排列:
00000000 00000000 00000000 00000000
BLUE GREED RED
用AND OR 等位运算函数可以改变
找到每个点的RGB值,
 
//下面的程序用于将图片中的蓝色擦除(过滤)
type
PColorArray = ^TColorArray;
TColorArray = array[0..32767] of TColor;

procedure TForm1.Button1Click(Sender: TObject);
var
x,y : Integer;
BitMap : TBitMap;
P : PColorArray;
begin
BitMap := TBitMap.create;
BitMap.PixelFormat:=pf32bit;
try
BitMap.LoadFromFile('未命名.BMP');
for y := 0 to BitMap.Height -1 do
begin
P := BitMap.ScanLine[y];
Edit1.Text := IntToStr(P[0]);
for x := 0 to BitMap.Width -1 do
P[x] := (P[x] or clBlue) xor clBlue;
end;
Canvas.Draw(0,0,BitMap);
finally
BitMap.Free;
end;
end;
 
接受答案了.
 
顶部