你说的也就是图像的镜像喽,
代码如下
procedure TForm1.LeftRightMirror(bitmap: TBitmap);
var
bmp1, bmp2, bmp3: TBitmap;
T, P: pByteArray;
X, Y: integer;
begin
bmp1 := TBitmap.Create;
bmp2 := TBitmap.Create;
bmp3 := TBitmap.Create;
bmp2.Assign(bitmap);
bmp1.Assign(bitmap);
bmp3.Width := 2 * bmp1.Width;
bmp3.Height := bitmap.Height;
for Y := 0 to bmp2.Height - 1 do
begin
T := bmp2.ScanLine[Y];
P := bmp1.ScanLine[Y];
for X := 0 to bmp2.Width - 1 do
begin
P[3 * X + 2] := T[3 * (bmp2.Width - 1 - X) + 2];
P[3 * X + 1] := T[3 * (bmp2.Width - 1 - X) + 1];
P[3 * X] := T[3 * (bmp2.Width - 1 - X)];
end;
end;
bmp3.Canvas.Draw(0, 0, bmp2);
bmp3.Canvas.Draw(bmp2.Width, 0, bmp1);
bitmap.Assign(bmp3);
bmp1.Free;
bmp2.Free;
bmp3.Free;
end;