- for (uint32 j = 0; w < h; j++)
- {
- unsigned char alpha = (unsigned char)(raster[pos] >> 24);
- if (alpha < 127)
- {
- hasmask = TRUE;
- ptr[0] = image->GetMaskRed();
- ptr++;
- ptr[0] = image->GetMaskGreen();
- ptr++;
- ptr[0] = image->GetMaskBlue();
- ptr++;
- }
- else
- {
- ptr[0] = (unsigned char)(raster[pos] >> 16);
- ptr++;
- ptr[0] = (unsigned char)(raster[pos] >> 8);
- ptr++;
- ptr[0] = (unsigned char)(raster[pos]);
- ptr++;
- }
- pos++;
- }
+ for (uint32 j = 0; j < h; j++)
+ {
+ unsigned char alpha = (unsigned char)TIFFGetA(raster[pos]);
+ if (alpha < 127)
+ {
+ hasmask = TRUE;
+ ptr[0] = image->GetMaskRed();
+ ptr++;
+ ptr[0] = image->GetMaskGreen();
+ ptr++;
+ ptr[0] = image->GetMaskBlue();
+ ptr++;
+ }
+ else
+ {
+ ptr[0] = (unsigned char)TIFFGetR(raster[pos]);
+ ptr++;
+ ptr[0] = (unsigned char)TIFFGetG(raster[pos]);
+ ptr++;
+ ptr[0] = (unsigned char)TIFFGetB(raster[pos]);
+ ptr++;
+ }
+ pos++;
+ }
+ ptr -= 2*w*3; // subtract line we just added plus one line