Note: You must be registered in order to post a reply. To register, click here. Registration is FREE!
T O P I C R E V I E W
xequte
Posted - Sep 07 2020 : 01:35:16 You will get this error when trying to perform an image editing function (such as Proc.Rotate) when an image layer is not selected.
To prevent this, check the type of layer, e.g.
// Calculate number of colors in current image
procedure TMainForm.miCalccolornumberClick(Sender: TObject);
var
nc: integer;
begin
if ImageEnView1.CurrentLayer.Kind <> ielkImage then
ShowMessage('An image layer is not selected')
else
begin
nc := ImageEnView1.Proc.CalcImageNumColors;
ShowMessage('The active images has ' + inttostr(nc) + ' colors.');
end;
end;
Posted - Sep 08 2020 : 05:35:26 Wouldn't this be a reliable solution:
var OldActiveLayer: Integer;
OldActiveLayer := ImageEnView1.LayersCurrent;
try
// if you only want to get the number of colors in your TImageEnView image
ImageEnView1.LayersCurrent := 0;
nc := ImageEnView1.Proc.CalcImageNumColors;
finally
ImageEnView1.LayersCurrent := OldActiveLayer;
end;