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
 Converting to 8bit
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

haya

7 Posts

Posted - Feb 26 2020 :  08:01:59  Show Profile  Reply
I need to get screenshot, convert it to 8bit bitmap and save to TMemoryStream. so i wrote this code but get Access Violation error. What's wrong?:

var Stream:= TMemoryStream.Create;
ImageEnIO.CaptureFromScreen(iecsScreen, crNone);
ImageEnIO.IEBitmap.PixelFormat := ie8g;
ImageEnIO.SaveToStreamBmp(Stream);
Stream.Position:= 0;
img1.Picture.LoadFromStream(Stream);

xequte

38175 Posts

Posted - Feb 26 2020 :  17:49:18  Show Profile  Reply
Hi

Please also set the BitsPerSample and SamplesPerPixel appropriately:

Stream := TMemoryStream.Create;
ImageEnView1.IO.CaptureFromScreen(iecsScreen, crNone);
ImageEnView1.IO.IEBitmap.PixelFormat := ie8g;
ImageEnView1.IO.Params.BitsPerSample := 8;
ImageEnView1.IO.Params.SamplesPerPixel := 1;
ImageEnView1.IO.SaveToStreamBmp(Stream);
Stream.Position:= 0;
image1.Picture.LoadFromStream(Stream);
Stream.Free;


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

xequte

38175 Posts

Posted - Aug 05 2020 :  20:21:37  Show Profile  Reply
Hi

FYI, in 9.1.2 you can automatically handle this by calling:

IEGlobalSettings().AutoSetBitDepth := True;

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