wxImage.SaveFile into stream with TIFF format gives corrupted data

wxImage.SaveFile into stream with TIFF format gives corrupted data

Post by calenda » Sat, 28 Mar 2009 07:20:47


Hello,

I am saving a wxImage in TIFF format. If I do:

TempImage.SaveFile(FileName, wxBITMAP_TYPE_TIF);

Everything is fine and the image file is ok.

But if I do:

wxMemoryOutputStream *mos = new wxMemoryOutputStream();
TempImage.SaveFile(*mos,wxBITMAP_TYPE_TIF);
buff_size = mos->CopyTo(buff,buff_size);

then buff_size is around 2Kb less then the file size from above and if
I save the buffer to disk the file is not a valid TIFF file. I binary
compared the two files and they are identical except this one is
missing the ~2Kb data at the end.

Does anybody know if this is a bug in the TIFF image handler? If I do
the exact same with wxBITMAP_TYPE_JPEG it works fine.

Thanks,
Gerhard.
 
 
 

wxImage.SaveFile into stream with TIFF format gives corrupted data

Post by Vadim Zeit » Sat, 28 Mar 2009 08:14:22


I don't see anything in TIFF handler code which could explain this so this
would definitely need to be debugged to understand what's going on. If you
can do it, please try to see what happens with these last 2Kb of data, e.g.
whether they're passed to wxTIFFWriteProc() and what does it do with them.
If not but if you can make a reproducible test case for this bug please
open a Trac ticket for it.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.yqcomputer.com/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)

iEYEABECAAYFAknMDE4ACgkQBupB3k9sHobnbQCdET7eOKEwQLV1BANW2bW9lhN1
ap0AnRydA0v2J+NaG+wKR9nov7cXNH23
=6QiX
-----END PGP SIGNATURE-----

 
 
 

wxImage.SaveFile into stream with TIFF format gives corrupted data

Post by calenda » Wed, 01 Apr 2009 01:53:29


>
> pplication_pgp-signature>p<rt
> < 1KViewDownload

Hello Vadim,

Thanks for your reply. It really seems to be a bug in the tiff
handler. After all the image data is written, the directory is
supposed to be written at the end of the file. However no memory is
allocated for that. My boss found it and fixed it the following way:

In file tif_dirwrite.c in line 171 right before TIFFSeekFile he added
the following code:

char ch = 0;
int len>= tif->tif_dataoff>- tif->tif_curoff;
(void) TIFFSeekFile(ti>, tif->tif_curoff, SEEK_SET);

whil> (len > 0)
{
WriteOK(tif, &ch, 1);
len--;
}

I don't know how to open a trac ticket, can someone look at this and
do it? Thx!

Regards,
Gerhard Bork.