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
 Grayscale Question
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

pierrotsc

USA
499 Posts

Posted - Feb 09 2012 :  13:17:58  Show Profile  Reply
How can I find out if an image i load is a 256 grayscale image? If it is not, how can I convert it to one?
Thanks.
P

w2m

USA
1990 Posts

Posted - Feb 09 2012 :  14:59:10  Show Profile  Reply
Try this:

procedure ConvertTo256Grayscale;
begin
  {This method converts selected region to gray levels. The image   always will be in true color (16M of colors)}
 ImageENView1.Proc.ConvertToGray;

{Converts current image to 256 colors}
 ImageENView1.Proc.ConvertTo( 256 );
end;


{ not tested }
function IsImageGrayscale: boolean;
begin
  Result := ImageENView1.IEBitmap.PixelFormat = ie8g;
  // gray scale (256 levels)
end;


or

{ not tested }
function IsImageGrayscale: boolean;
begin
  Result := (ImageENView1.IEBitmap.IsGrayScale) and (ImageENView1.IO.Params.BitsPerSample * ImageENView1.IO.Params.SamplesPerPixel = 8);       
// Checks if all pixels have have R=G=B values (the bitmap is grayscale)... BitsPerSample * SamplesPerPixel = 8 bit 256 color
end;


William Miller
Go to Top of Page

pierrotsc

USA
499 Posts

Posted - Feb 10 2012 :  14:08:07  Show Profile  Reply
Thanks...Will try that..
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: