| ImageEn, unit imageenproc |
|
TImageEnProc.BeginImageProcessing
Declaration
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.
Example
procedure CustomNegative( proc: TImageEnProc );
var
procBmp: TIEBitmap;
mask: TIEMask;
X1, Y1, X2, Y2: Integer;
x, y: Integer;
px: PRGB;
begin
if not proc.BeginImageProcessing([ie24RGB], X1, Y1, X2, Y2, 'CustomNegative', procBmp, 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( procBmp, mask );
end;
..
ImageEnView1.SelectEllipse( 100, 100, 100, 100 );
CustomNegative( ImageEnView1.Proc );