画像を180度回転させます。今回も特に説明は要らないでしょう。
procedure Rotate180(Source: TBitmap);
var
X, Y, W, H: Integer;
pS1, pS2: PLine24;
pSrcCache: PCacheLines;
Temp: TRGB24;
begin
W := Source.Width;
H := Source.Height;
Source.PixelFormat := pf24bit;
pSrcCache := GetCacheLines(Source);
try
Dec(W);
Dec(H);
for Y := 0 to H do
begin
pS1 := pSrcCache^[Y];
pS2 := pSrcCache^[H-Y];
for X := 0 to W div 2 do
begin
Temp := pS1^[X];
pS1^[X] := pS2^[W-X];
pS2^[W-X] := Temp;
end;
end;
finally
FreeMem(pSrcCache);
end;
if Assigned(Source.OnChange) then
Source.OnChange(Source);
end;
|