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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 "Active layer does not contain bitmap"
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

xequte

38179 Posts

Posted - Sep 07 2020 :  01:35:16  Show Profile  Reply
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;



Nigel
Xequte Software
www.imageen.com

PeterPanino

860 Posts

Posted - Sep 08 2020 :  05:35:26  Show Profile  Reply
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;
Go to Top of Page

xequte

38179 Posts

Posted - Sep 08 2020 :  05:56:34  Show Profile  Reply
Yes, that is correct.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: