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
 MIO.NativePixelFormat
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

aleatprog

21 Posts

Posted - Apr 07 2019 :  13:16:04  Show Profile  Reply
I need to open and save an 8 bit grey scale multipage TIF.


The following code should open the single images as 8 bit IEBitmap:

TImageEnMView.MIO.NativePixelFormat := True;
iPageCount := EnumTIFFIm(path);
for i := 0 to iPageCount - 1 do
TImageEnMView.AppendImage(path + IEM_Path_Index_Delimiter + IntToStr(i));


I added the following lines in order to check the pixel format:

bmp := TImageEnMView.GetTIEBitmap(0);
bit := bmp.BitCount;


bit value is 24, not 8. May you tell me what is missing in the code above?

Thanks,
Ale

aleatprog

21 Posts

Posted - Apr 07 2019 :  13:34:20  Show Profile  Reply
Part 2: The following code generates an 24bit instead of an 8bit TIFF:


for i := 0 to TImageEnMView.MultiSelectedImagesCount - 1 do
begin
  bmp := TImageEnMView.GetTIEBitmap(i);
  TImageEnMView.LockUpdate();
  with TImageEnProc.CreateFromBitmap(bmp) do
  begin
    ConvertTo(ie8g);
    Free;
  end;
  TImageEnMView.UnlockUpdate();
  TImageEnMView.ReleaseBitmap(i, True);
  TImageEnMView.MIO.Params[i].TIFF_Compression := ioTIFF_JPEG;
  TImageEnMView.MIO.SaveToFileTIFF(Path, True);
end;



What should be changed in order to create an 8bit TIFF?

Ale
Go to Top of Page

xequte

4538 Posts

Posted - Apr 08 2019 :  01:44:25  Show Profile  Reply
Hi

When you use AppendImage, it does not use MIO, so NativePixelFormat is ignored. You can load like this instead:

ImageEnMView1.MIO.NativePixelFormat := True;
ImageEnMView1.MIO.Read( path );


Regarding your second part of code, firstly, ensure LockUpdate/UnlockUpdate are wrapped around the entirety of your code, e.g.


ImageEnMView1.LockUpdate();
for i := 0 to ImageEnMView1.MultiSelectedImagesCount - 1 do
begin
  bmp := ImageEnMView1.GetTIEBitmap(i);
  with TImageEnProc.CreateFromBitmap(bmp) do
  begin
    ConvertTo(ie8g);
    Free;
  end;
  ImageEnMView1.ReleaseBitmap(i, True);
  ImageEnMView1.MIO.Params[i].TIFF_Compression := ioTIFF_JPEG;
end;
ImageEnMView1.UnlockUpdate();
ImageEnMView1.MIO.SaveToFileTIFF(Path, True);


Secondly, try just setting:

bmp.PixelFormat := ie8g;

Otherwise, I'll need to check it when I am in the office tomorrow.


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

aleatprog

21 Posts

Posted - Apr 08 2019 :  08:55:29  Show Profile  Reply
Thank you, Nigel. I'll do some tests with ImageEnMView.MIO.Params[i].Read and ImageEnMView.MIO.LoadFromFileTIFF which I'd replaced with the current ImageEnMView.AppendImage.

Ale
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To: