The attached small test project demonstrates an issue with TImageEnProc.CalcImageNumColors
attach/PeterPanino/202442865416_IssueCalcNumColors.zip
77.11 KB
ImageEnView1.Proc.CalcImageNumColors();
creates an error if a non-image-layer exists:
To prevent this error, a current layer must explicitly be declared:
procedure TForm1.ButtonCalcNumColorsClick(Sender: TObject);
begin
// This is required to avoid an error if a non-image-layer exists:
ImageEnView1.LayersCurrent := 0;
// Suggestion: This should be done automatically in ImageEnView1.Proc.CalcImageNumColors()
// Or at least, there should be a Layer parameter that defaults to 0:
// TImageEnProc.CalcImageNumColors(ALayer: Integer = 0)
var n := ImageEnView1.Proc.CalcImageNumColors();
Self.Caption := IntToStr(n) + ' Colors';
end;
My suggestion: When attached to a TImageEnView, TImageEnProc.CalcImageNumColors should act on layer 0 per default.
Alternatively, there should be a Layer parameter that defaults to 0:
TImageEnProc.CalcImageNumColors(ALayer: Integer = 0)
What do you think?