FMX.AlphaColorToScanline (Delphi)

From RAD Studio XE3 Code Examples
Jump to: navigation, search

Description

This example shows how to use a AlphaColorToScanline method. AlphaColorToScanline is used to copy a specified number of lines from a bitmap to another bitmap.

Code

function TForm1.TestAlphaColorToScanline(ABitmap: TBitmap;
  start, count: integer): TBitmap;
var
  bitdata1, bitdata2: TBitmapData;
begin
  Result := TBitmap.Create(Round(ABitmap.Width), Round(count));
  if (ABitmap.Map(TMapAccess.maRead, bitdata1) and
    Result.Map(TMapAccess.maWrite, bitdata2)) then
  begin
    try
      AlphaColorToScanline(@PAlphaColorArray(bitdata1.Data)
        [start * (bitdata1.Pitch div GetPixelFormatBytes(ABitmap.PixelFormat))],
        bitdata2.Data, Round(Result.Height * Result.Width),
        ABitmap.PixelFormat);
    finally
      ABitmap.Unmap(bitdata1);
      Result.Unmap(bitdata2);
    end;
  end;
end;

Result example:

Input bitmap

TestAlphaColorToScanline(ABitmap, 100, 100)

(copy 100 lines, starting at line 100)

Input Bitmap.png

AlphaColorToScanline result.png

Uses

See Also