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*c])
+ pixels(new unsigned char[h*w*bytesPerPixel])
{}
inline ~Image() {
Image *
readPNG(const char *filename);
+
+struct PNMInfo
+{
+ unsigned width;
+ unsigned height;
+ unsigned channels;
+ ChannelType channelType;
+};
+
const char *
-readPNMHeader(const char *buffer, size_t size, unsigned *channels, unsigned *width, unsigned *height);
+readPNMHeader(const char *buffer, size_t size, PNMInfo &info);
+
+Image *
+readPNM(const char *buffer, size_t bufferSize);
} /* namespace image */