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
 wrong colors with b/w TIFF files
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

DRIGUS

21 Posts

Posted - Feb 23 2018 :  10:38:36  Show Profile  Reply
Hi *.*.

in the past we use something like the code below in order to load and process different image files:


var
  ImageIO: tImageEnIO;
  Buffer: tBitmap;

begin
  Buffer := tBitmap.Create;
  ImageIO := tImageEnIO.CreateFromBitmap(Buffer);
  ImageIO.LoadFromFile(aFileName1);

  Buffer.SaveToFile(aFileName2);

  ImageIO.Free;
  Buffer.Free;
end;


This leads sometimes (but not in all cases) to wrong colors when loading b/w TIFF files, f.e. the background is red instead of white. I can observe this behavior with ImageEn 6.3.2, 7.0.1 and 7.5.0, but not with an older version (must be a 4.x version), using Delphi 5 (yes, 5!).

It works as expected if I change the code like this:


var
  ImageIO: tImageEnIO;
  Buffer: tBitmap;

begin
  ImageIO := tImageEnIO.Create(nil);
  ImageIO.LoadFromFile(aFileName1);

  Buffer := tBitmap.Create;
  ImageIO.IEBitmap.CopyToTBitmap(Buffer);
  Buffer.SaveToFile(aFileName2);

  ImageIO.Free;
  Buffer.Free;
end;



Greetings

xequte

39061 Posts

Posted - Feb 23 2018 :  19:56:07  Show Profile  Reply
Hi

In the first example, does it work correctly if you set the TBitmap.PixelFormat before attaching it to the TImageEnIO?

Also, where possible use TIEBitmap, rather than TBitmap, which overcomes many of its limitations.



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

DRIGUS

21 Posts

Posted - Feb 26 2018 :  10:27:03  Show Profile  Reply
Hi.

Because we need a quick solution, I changed the code to use the internal TIEBitmap of TImageEnIO and call CopyToBitmap in order to get a TBitmap for further processing. This works as expected.

But if I remember right I tried something like


  Buffer := tBitmap.Create;
  Buffer.PixelFormat := pfDevice;
  Buffer.PixelFormat := pf1Bit;
  ImageIO := tImageEnIO.CreateFromBitmap(Buffer);
  ImageIO.LoadFromFile(aFileName1); 
  ... 


which seems to work, too.


Greetings.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: