Revert "avoid allocating memory"

This reverts commit 665c2f5bc0.
This commit is contained in:
artemp 2014-12-10 09:39:08 +01:00
parent 665c2f5bc0
commit ef64b4937c

View file

@ -309,11 +309,16 @@ void save_as_tiff(T1 & file, T2 const& image, tiff_config & config)
TIFFSetField(output, TIFFTAG_ROWSPERSTRIP, 1);
int next_scanline = 0;
typename T2::pixel_type * row = reinterpret_cast<typename T2::pixel_type*>(::operator new(image.getRowSize()));
while (next_scanline < height)
{
TIFFWriteScanline(output, const_cast<typename T2::pixel_type*>(image.getRow(next_scanline)), next_scanline, 0);
memcpy(row, image.getRow(next_scanline), image.getRowSize());
//typename T2::pixel_type * row = const_cast<typename T2::pixel_type *>(image.getRow(next_scanline));
TIFFWriteScanline(output, row, next_scanline, 0);
++next_scanline;
}
::operator delete(row);
}
else
{
@ -321,7 +326,11 @@ void save_as_tiff(T1 & file, T2 const& image, tiff_config & config)
TIFFSetField(output, TIFFTAG_TILELENGTH, height);
TIFFSetField(output, TIFFTAG_TILEDEPTH, 1);
// Process as tiles
TIFFWriteTile(output, const_cast<typename T2::pixel_type*>(image.getData()), 0, 0, 0, 0);
typename T2::pixel_type * image_data = reinterpret_cast<typename T2::pixel_type*>(::operator new(image.getSize()));
memcpy(image_data, image.getData(), image.getSize());
//typename T2::pixel_type * image_data = const_cast<typename T2::pixel_type *>(image.getData());
TIFFWriteTile(output, image_data, 0, 0, 0, 0);
::operator delete(image_data);
}
// TODO - handle palette images
// std::vector<mapnik::rgb> const& palette