unit ScanLineAdapter;
interface
type
IScanLineAdapter =
interface(IInterface)
['
{A19606EB-4B25-4862-86D5-ED26E7F07F8C}']
function GetScanLine(AIndex: Integer): Pointer;
end;
TScanLineAdapter =
class(TInterfacedObject, IScanLineAdapter)
protected
function GetScanLine(AIndex: Integer): Pointer;
virtual;
abstract;
end;
TBitmapScanLineAdapter =
class(TScanLineAdapter)
private
FItem: TBitmap;
protected
function GetScanLine(AIndex: Integer): Pointer;
override;
public
constructor Create(AItem: TBitmap);
end;
TPngImageScanLineAdapter =
class(TScanLineAdapter)
private
FItem: TPngImage;
protected
function GetScanLine(AIndex: Integer): Pointer;
override;
public
constructor Create(AItem: TPngImage);
end;
TPngImageAlphaScanLineAdapter =
class(TScanLineAdapter)
private
FItem: TPngImage;
protected
function GetScanLine(AIndex: Integer): Pointer;
override;
public
constructor Create(AItem: TPngImage);
end;
implementation
{ TBitmapScanLineAdapter }
constructor TBitmapScanLineAdapter.Create(AItem: TBitmap);
begin
inherited Create;
FItem := AItem;
end;
function TBitmapScanLineAdapter.GetScanLine(AIndex: Integer): Pointer;
begin
Result := FItem.ScanLine[AIndex];
end;
{ TPngImageScanLineAdapter }
constructor TPngImageScanLineAdapter.Create(AItem: TPngImage);
begin
inherited Create;
FItem := AItem;
end;
function TPngImageScanLineAdapter.GetScanLine(AIndex: Integer): Pointer;
begin
Result := FItem.ScanLine[AIndex];
end;
{ TPngImageAlphaScanLineAdapter }
constructor TPngImageAlphaScanLineAdapter.Create(AItem: TPngImage);
begin
inherited Create;
FItem := AItem;
end;
function TPngImageAlphaScanLineAdapter.GetScanLine(AIndex: Integer): Pointer;
begin
Result := FItem.AlphaScanline[AIndex];
end;
end.