ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 TImageEnProc.CalcImageNumColors Issue

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
PeterPanino Posted - Apr 28 2024 : 07:08:30
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?

1   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Apr 28 2024 : 20:00:20
Hi Peter

This will occur with any TImageEnProc method that requires a bitmap.

The question is what should TImageEnProc do when a method is called when there is not an active bitmap layer. I don't think we should presume what the user wants in this situation.

Maybe they do want a count of layers in the background image, or maybe they want a count of images in the current layer (unaware that the operation is not available for non-image layers).

I think it is better to return an error so that the developer knows the code is not working as they anticipated, rather than silently return a result that *seems valid*, but is not (developer does not know the count returned is for layer 0, rather than the current layer).

Nigel
Xequte Software
www.imageen.com