ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Corrupt TIFF-Images

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Harald Posted - Jun 15 2011 : 01:35:05
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
2   L A T E S T    R E P L I E S    (Newest First)
Harald Posted - Jun 16 2011 : 05:53:52
Update to 3.1.2 fix the problem.

Document Management http://www.officemanager.de
fab Posted - Jun 15 2011 : 02:06:41
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.