function BeginImageProcessing(allowedFormats: TIEPixelFormats; var x1, y1, x2, y2: Integer; const OpName: String; var ProcBitmap: TIEBitmap; var mask: TIEMask; OpID: Integer = 0; ExtractROI: Boolean = true): Boolean;
Description
BeginImageProcessing and EndImageProcessing allow you to create custom image processing functions that automatically handle selection area, pixel format consistency and undo.
Parameter
Description
AllowedFormats
The permitted pixel formats
x1, y1, x2, y2
The destination rectangle coordinates to apply the function
OpName
A string describing the function (for the undo caption)
ProcBitmap
The bitmap to process
mask
The selection mask
OpID
An optional ID for the task which is saved with the undo (and available via GetUndoInfo). Any value can be specified or a Undo Constant. Use -1 to skip saving of the undo
ExtractROI
If true (default) ProcBitmap contains only the Region Of Interest, otherwise it contains the full original bitmap
By using BeginImageProcessing/EndImageProcessing, you can avoid considering if the selection is rectangle, elliptical, irregular or magic wand, just process the bitmap as a rectangle.
procedure CustomNegative( proc: TImageEnProc ); var ProcBitmap: TIEBitmap; mask: TIEMask; x1, y1, x2, y2: Integer; x, y: Integer; px: PRGB; begin // we support only ie24RGB format if not proc.BeginImageProcessing([ie24RGB], x1, y1, x2, y2, 'CustomNegative', ProcBitmap, mask) then exit; for y := y1 to y2-1 do begin px := ProcBitmap.Scanline[y]; for x := x1 to x2-1 do begin with px^ do begin r := 255-r; g := 255-g; b := 255-b; end; inc(px); end; end; // finalize proc.EndImageProcessing(ProcBitmap, mask); end;