ImageEn, unit imageenproc

TImageEnProc.CreateFromBitmap

TImageEnProc.CreateFromBitmap


Declaration

constructor CreateFromBitmap(Bitmap: TIEBitmap);
constructor CreateFromBitmap(Bitmap: TBitmap);


Description

Creates a new instance of TImageEnProc assigning the property AttachedIEBitmap or AttachedBitmap.

Note: Also sets AutoUndo to false.


Examples

// Draw text onto a TBitmap or TIEBitmap
with TImageEnProc.CreateFromBitmap(myBitmap) do
begin
  TextOut(Align_Text_Horz_Center, Align_Text_Near_Bottom, 'Me in Italy - 2015', 'Arial', 32, clRed, [fsBold]);
  Free;
end;


// Load an image with a TBitmap, make it negative then save it
bmp := TBitmap.Create;
bmp.LoadFromFile('D:\image.bmp');
proc := TImageEnProc.CreateFromBitmap(bmp);
proc.Negative();
proc.Free;
bmp.SaveToFile('D:\output.bmp');
bmp.Free;


// Load an image rotate it 270 deg. clockwise and then save it
iebmp := TIEBitmap.Create();
iebmp.LoadFromFile('D:\image.jpeg');
proc := TImageEnProc.CreateFromBitmap(iebmp);
proc.Rotate(90);
proc.Free;
iebmp.SaveToFile('D:\output.jpeg');
iebmp.Free;


// Deskew all selected scanned documents
ImageEnMView1.LockUpdate();
try
  for i := 0 to ImageEnMView1.MultiSelectedImagesCount-1 do
  begin
    selIdx := ImageEnMView1.MultiSelectedImages[i];
    bmp := ImageEnMView1.GetTIEBitmap( selIdx );
    try
      proc := TImageEnProc.CreateFromBitmap( bmp );
      try
        nAngle := proc.SkewDetection();
        proc.RotateAndCrop( nAngle, ierBilinear, bmp.Height / bmp.Width, iecaSkewedDocument );
      finally
        FreeAndNil(proc);
      end;

    finally
      ImageEnMView1.ReleaseBitmap( selIdx, True );
    end;
  end;
finally
  ImageEnMView1.UnlockUpdate();
end;