unsigned height;
unsigned channels;
ChannelType channelType;
+ unsigned bytesPerChannel;
unsigned bytesPerPixel;
// Flipped vertically or not
height(h),
channels(c),
channelType(t),
- bytesPerPixel(channels * (t == TYPE_FLOAT ? 4 : 1)),
+ bytesPerChannel(t == TYPE_FLOAT ? 4 : 1),
+ bytesPerPixel(channels * bytesPerChannel),
flipped(f),
pixels(new unsigned char[h*w*bytesPerPixel])
{}
* Need to add/remove channels, one pixel at a time.
*/
- unsigned char *tmp = new unsigned char[width*bytesPerPixel];
+ unsigned char *tmp = new unsigned char[width*outChannels*bytesPerChannel];
if (channelType == TYPE_UNORM8) {
/*
*dst++ = 0;
}
}
- os.write((const char *)tmp, width*bytesPerPixel);
+ os.write((const char *)tmp, width*outChannels*bytesPerChannel);
}
}