//
{Copyright(c)2000 Advanced Delphi Systems
Richard Maley
Advanced Delphi Systems
12613 Maidens Bower Drive
Potomac, MD 20854 USA
phone 301-840-1554
maley@advdelphisys.com
The code herein can be used or modified by anyone. Please retain references
to Richard Maley at Advanced Delphi Systems. If you make improvements to the
code please send your improvements to maley@advdelphisys.com so that the
entire Delphi community can benefit. All comments are welcome.
Please note if you are viewing this Delphi unit as a web page all you have to
do to turn it into a Delphi unit is save it with a ".pas" extension. The
html in the unit should not affect its performance.
}
unit ads_BitmapFlip;
(*UnitIndex Master Index Implementation Section Download UnitsDescription: ads_BitmapFlip.pas This unit contains the following routines.
*) interface Uses Windows,Graphics; Function BitmapFlip( Const Vertical : Boolean; Const Horizontal : Boolean; var BitmapIn : TBitmap; out BitmapOut : TBitmap): Boolean; implementation Type TColorData = Array[0..128000] Of TRGBTriple; pColorData = ^TColorData; //Unit Description UnitIndex Master Index
Function BitmapFlip(
Const Vertical : Boolean;
Const Horizontal : Boolean;
var BitmapIn : TBitmap;
out BitmapOut : TBitmap): Boolean;
Var
DataIn : pColorData;
DataOut : pColorData;
inRow : Integer;
inCol : Integer;
Begin
Result := False;
Try
If BitmapIn.PixelFormat <> pf24bit Then Exit;
With BitmapOut Do
Begin
Width := BitmapIn.Width;
Height := BitmapIn.Height;
PixelFormat := BitmapIn.PixelFormat;
End;
For inRow := 0 To BitmapIn.Height - 1 Do
Begin
DataIn := BitmapIn.Scanline[inRow];
If Vertical Then
Begin
DataOut := BitmapOut.ScanLine[BitmapIn.Height - 1 - inRow];
End
Else
Begin
DataOut := BitmapOut.ScanLine[inRow];
End;
If Horizontal Then
Begin
For inCol := 0 To BitmapIn.Width-1 Do DataOut[inCol] := DataIn[BitmapIn.Width-1-inCol];
End
Else
Begin
For inCol := 0 To BitmapIn.Width-1 Do DataOut[inCol] := DataIn[inCol];
End;
End;
Result := True;
Except
End;
End;
End.
//