unbearably slow when saving an non-compressed TIFF file using wxtiff

Ludvik Haomin.Liu at gmail.com
Wed Sep 6 02:26:32 PDT 2006


Vadim,

Problem resolved, it looks use pure libtiff to save a tiff file is
_much_much_
faster than wxTIFFHandler::SaveFile().

The problem seems lies here:

TIFF*
TIFFwxOpen(wxInputStream &stream, const char* name, const char* mode)
{
    TIFF* tif = TIFFClientOpen(name, mode,
        (thandle_t) &stream,
        _tiffReadProc, _tiffNullProc,
        _tiffSeekIProc, _tiffCloseProc, _tiffSizeProc,
        _tiffMapProc, _tiffUnmapProc);

    return tif;
}

wxTIFFHandler::SaveFile() use this customized TIFFwxOpen to open an
tiff file.
this cause it much slower than using pure libtiff function.

I have confirmed this in my codes. I copied wxTIFFHandler::SaveFile()'s
implementation
and changed it's first line from:

bool wxTIFFHandler::SaveFile( wxImage *image, wxOutputStream& stream,
bool verbose )
{
	TIFF *tif = TIFFwxOpen( stream, "image", "w" );

	...............
}

To:

bool MySaveTiffFile( wxImage *image, const char *outfn )
{
	TIFF *tif = TIFFOpen(outfn, "w");

	...........
}

Then I replaced wxTIFFHandler::SaveFile(), instead using
MySaveTiffFile() to convert
a wxImage Object to tiff file. This time, the speed is about 10 times
faster than before.

Now I don't know exactly why this change could bring me that much
improve on speed. However, the problem is solved, cheers!

;-)

Regards,
Ludvik

Vadim Zeitlin 写道:

> On 5 Sep 2006 01:30:46 -0700 Ludvik <Haomin.Liu at gmail.com> wrote:
>
> L> Now, .tiff files can be succesfully saved out, but the speed is
> L> unbearably slow: Saving a 1000 * 1000 pixel image could use up to 20
> L> seconds!
> L>
> L> Is there ways to improve the saving tiff archive speed??
>
>  Is this with the built in library version or the system one?
>
>  Anyhow, I don't really know what's going on here, maybe the saving is so
> slow because the uncompressed TIFF files are huge (what is the size of the
> output?). You'd need to save a file using libtiff directly to know if the
> problem is in wx wrapping of it or the library itself. Or maybe profile the
> code and see if it spends an inordinate amount of time in wx parts.
>
>  Regards,
> VZ
> --
> TT-Solutions: wxWidgets consultancy and technical support
>                http://www.tt-solutions.com/
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org







More information about the wx-users mailing list