ImageEn, unit iexBitmaps

TIEMask.ScanLine

TIEMask.ScanLine


Declaration

property ScanLine[row: integer]: pointer;


Description

This is equivalent to the Scanline property of TBitmap. It allows you to get/set the mask by hand.


Example

// Set all pixels within selection as red
// Same as ImageEnView1.SetSelectedPixelsColor
var
  x, y: Integer;
  pSel: pbyte;
  pPix: PRGB;
begin
  if ImageEnView1.SelectionMask.IsEmpty then
    raise Exception.create( 'Nothing selected' );

  if ImageEnView1.IEBitmap.PixelFormat <> ie24RGB then
    raise Exception.create( 'Not 24bit' );

  // Process selected area
  for y := 0 to ImageEnView1.SelectionMask.Height - 1 do
  begin
    pSel := ImageEnView1.SelectionMask.ScanLine[ y ];
    pPix := ImageEnView1.IEBitmap.ScanLine[ y ];

    case ImageEnView1.SelectionMask.BitsPerPixel of
      1:
        for x := 0 to ImageEnView1.SelectionMask.Width - 1 do
        begin
          // 1 Bit mask (values are 0 or 1)
          if (pbytearray(pSel)^[x shr 3] and iebitmask1[x and $7]) <> 0 then
          begin
            pPix^.R := 255;
            pPix^.G := 0;
            pPix^.B := 0;
          end;
          inc( pPix );
        end;
      8:
        for x := 0 to ImageEnView1.SelectionMask.Width - 1 do
        begin
          // 8 Bit mask (values are 0 to 255)
          if pSel^ <> 0 then
          begin
            pPix^.R := 255;
            pPix^.G := 0;
            pPix^.B := 0;
          end;
          inc( pSel );
          inc( pPix );
        end;
    end;
  end;
  ImageEnView1.Update();
end;