ImageEn, unit iexBitmaps

TIEMask.SetPixel

TIEMask.SetPixel


Declaration

procedure SetPixel(x, y: integer; Alpha: integer);


Description

Set a single pixel selection at x, y coordinates.
If the selection depth is 1 bit, then 0 is unselected and 1 is selected.
If the selection depth is 8 bit, then 0 is unselected, 1 - 254 is partially selected and 255 is fully selected.


Demo

Demo  Demos\Other\CellsAndGrid\CellsAndGrid.dpr


Examples

// Select all pixels that are blue or green (SelectionMaskDepth=1)
for y := 0 to ImageEnView1.IEBitmap.Height - 1 do
  for x := 0 to ImageEnView1.IEBitmap.Width - 1 do
  begin
    color := ImageEnView1.IEBitmap.Pixels[x, y];
    if ( color = clBlue ) or ( color = clGreen ) then
    begin
      ImageEnView.SelectionMask.SetPixel(X, Y, 1);
      ImageEnView.SelectCustom();
    end;
  end;


// Make a gradient selection (increasing from unselected to fully selected along height of image)
// Then convert selection to gray scale
ImageEnView1.Deselect();
ImageEnView1.SelectionMaskDepth := 8;
for Y := 0 to ImageEnView1.IEBitmap.Height - 1 do
  for X := 0 to ImageEnView1.IEBitmap.Width - 1 do
  begin
    selIntensity := Round( Y / ImageEnView1.IEBitmap.Height * 255 );
    ImageEnView1.SelectionMask.SetPixel( X, Y, selIntensity );
  end;
ImageEnView1.SelectCustom;
ImageEnView1.Proc.ConvertToGray();
ImageEnView1.Deselect();




// Turn image into chessboard pattern
ImageEnView1.Deselect();
ImageEnView1.SelectionMaskDepth := 1;
for Y := 0 to ImageEnView1.IEBitmap.Height - 1 do
  for X := 0 to ImageEnView1.IEBitmap.Width - 1 do
  begin
    if x div SQUARE_SIZE mod 2 = 0 then
      sel := True
    else
      sel := False;
    if y div SQUARE_SIZE mod 2 = 0 then
      sel := not sel;

    if sel then
      ImageEnView1.SelectionMask.SetPixel( X, Y, 1 )
    else
      ImageEnView1.SelectionMask.SetPixel( X, Y, 0 );
  end;
ImageEnView1.SelectCustom;
ImageEnView1.Proc.ConvertToGray();
ImageEnView1.Deselect();