-
Notifications
You must be signed in to change notification settings - Fork 6
Working with images
Martijn Koopman edited this page Jun 13, 2019
·
5 revisions
Required include for images:
#include <spatium/Image.h>
Grayscale (1x 8-bit channel)
spatium::Image<unsigned char, 1> grayImage(640, 480);
RGB (3x 8-bit channel)
spatium::Image<unsigned char, 3> rgbImage(640, 480);
RGBA (4x 8-bit channel)
spatium::Image<unsigned char, 4> rgbaImage(640, 480);
Required include for reading and writing:
#include <spatium/ImageIO.h>
The following image file formats are supported:
- Portable Bit Map (*.pbm)
- Portable Gray Map (*.pgm)
- Portable Pixel Map (*.ppm)
- Portable Arbitrary Map (*.pam)
These are simple file formats. The first 3 are widely accepted and can be created with various software applications including GIMP. However, these do not support transparency, i.e., an alpha channel. The 4th file format does support transparency, but it is not widely accepted. The only known software application to support this format is XnView.
Image format matrix
PBM | PGM | PPM | PAM | |
---|---|---|---|---|
Binary | X | X | ||
Grayscale | X | X | ||
Grayscale + alpha | X | |||
RGB | X | X | ||
RGB + alpha | X |
#include <spatium/Image.h>
#include <spatium/ImageIO.h>
// Create an empty RGBA image
spatium::Image<unsigned char, 4> imageRgba();
// Read from PAM file
//bool success = spatium::ImageIO::readRgbaImageFromPam("rgba_image.pam", imageRgba)); // NOT YET IMPLEMENTED
#include <spatium/Image.h>
#include <spatium/ImageIO.h>
// Create an empty RGBA image
spatium::Image<unsigned char, 4> imageRgba(640, 480);
// Write to PAM file
bool success = spatium::ImageIO::writeRgbaImageAsPam(imageRgba, "rgba_image.pam"));