Added support for saving greyscale TIFF images.

When saving with a samples per pixel value of 1 the TIFF handler still treated the image as RGB, resulting in corrupted images. Handle the greyscale case and added a unit test for it.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68784 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Dimitri Schoolwerth
2011-08-19 02:35:48 +00:00
parent 7f77b25ea8
commit 8e28cc4701
2 changed files with 8 additions and 0 deletions

View File

@@ -659,6 +659,13 @@ bool wxTIFFHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbo
// color image // color image
memcpy(buf, ptr, image->GetWidth()); memcpy(buf, ptr, image->GetWidth());
} }
else if (spp * bps == 8) // greyscale image
{
for ( int column = 0; column < linebytes; column++ )
{
buf[column] = ptr[column*3 + 1];
}
}
else // black and white image else // black and white image
{ {
for ( int column = 0; column < linebytes; column++ ) for ( int column = 0; column < linebytes; column++ )

View File

@@ -1115,6 +1115,7 @@ static void TestTIFFImage(const wxString& option, int value)
void ImageTestCase::SaveTIFF() void ImageTestCase::SaveTIFF()
{ {
TestTIFFImage(wxIMAGE_OPTION_TIFF_BITSPERSAMPLE, 1); TestTIFFImage(wxIMAGE_OPTION_TIFF_BITSPERSAMPLE, 1);
TestTIFFImage(wxIMAGE_OPTION_TIFF_SAMPLESPERPIXEL, 1);
} }
void ImageTestCase::SaveAnimatedGIF() void ImageTestCase::SaveAnimatedGIF()