白い色を他の色に変えたいと思いますか?もしそうなら、私はあなたがピクセルごとに画像をチェックし、ピクセルが何色であるかをチェックし、そしてそれが白であるならばそれを変えるべきだと思います。
それがあなたが画像をループする方法です
var
iX : Integer;
Line: PByteArray;
...
Line := Image1.ScanLine[0]; // We are scanning the first line
iX := 0;
// We can't use the 'for' loop because iX could not be modified from
// within the loop
repeat
Line[iX] := Line[iX] - $F; // Red value
Line[iX + 1] := Line[iX] - $F; // Green value
Line[iX + 2] := Line[iX] - $F; // Blue value
Inc(iX, 3); // Move to next pixel
until iX > (Image1.Width - 1) * 3;
赤と青の値を読み取り、それらを切り替える方法を示すコードを次に示します。
var
btTemp: Byte; // Used to swap colors
iY, iX: Integer;
Line : PByteArray;
...
for iY := 0 to Image1.Height - 1 do begin
Line := Image1.ScanLine[iY]; // Read the current line
repeat
btSwap := Line[iX]; // Save red value
Line[iX] := Line[iX + 2]; // Switch red with blue
Line[iX + 2] := btSwap; // Switch blue with previously saved red
// Line[iX + 1] - Green value, not used in example
Inc(iX, 3);
until iX > (Image1.Width - 1) * 3;
end;
Image1.Invalidate; // Redraw bitmap after everything's done
ただし、これはビットマップイメージ専用です。
これが役立つ場合は、画像をビットマップに変換してから操作してみてください。