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
 Corrupt TIFF-Images
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Harald

Germany
8 Posts

Posted - Jun 15 2011 :  01:35:05  Show Profile  Reply
Hello.

ImgStream2 contains a scanned image.
The following code converts the image from BMP to TIFF:

procedure TImageListItem.MyTest;
var LBmp  : TIEBitmap;
    LImgIO: TImageEnIO;
begin
  // Test file 1...
  TMemoryStream(ImgStream2).SaveToFile(OmTmpPath + 'Img.bmp');
  // Convert...
  LBmp   := TIEBitmap.Create;
  LImgIO := TImageEnIO.Create(nil);
  try
    ImgStream2.Position := 0;
    LImgIO.AttachedIEBitmap := LBmp;
    LImgIO.Params.TIFF_ImageIndex := 0;
    LImgIO.LoadFromStreamFormat(ImgStream2, IEExtToFileFormat('bmp'));
    LImgIO.Params.TIFF_Compression := ioTIFF_G4FAX;
    TMemoryStream(ImgStream2).Clear;
    LImgIO.AttachedIEBitmap := LBmp;
    LImgIO.SaveToStream(ImgStream2, IEExtToFileFormat('tif'));
    // Test file 2...
    TMemoryStream(ImgStream2).SaveToFile(OmTmpPath + 'Img.tif');
  finally
    LBmp.Free;
    LImgIO.Free;
  end;
end;


Sometimes the TIFF file is corrup after conversion,
Preview:

BMP and TIFF file:
http://www.officemanager.de/tmp/foren/imageen-bmp2tif.zip

I'm using ImageEn 3.1.1 with Delphi 2009.
Can you see an error in my code?

Thanks, Harald




Document Management http://www.officemanager.de

fab

1310 Posts

Posted - Jun 15 2011 :  02:06:41  Show Profile  Reply
The code seems OK. Anyway you should try this:

1) because G4FAX compression requires a black/white image (1bit) you should make sure it, executing:
...
LImgIO.Params.TIFF_Compression := ioTIFF_G4FAX;
LImgIO.Params.BitsPerSample := 1;
LImgIO.Params.SamplesPerPixel := 1;
if LBmp.PixelFormat <> ie1g then
  LBmp.PixelFormat := ie1g;
...


2) try the version 3.1.2, it fixes some minor bugs, maybe they are indirectly related to your problem.

I tried your code using version 3.1.2 and the bmp file your provided without problems.

Go to Top of Page

Harald

Germany
8 Posts

Posted - Jun 16 2011 :  05:53:52  Show Profile  Reply
Update to 3.1.2 fix the problem.

Document Management http://www.officemanager.de
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: