7. Save 12-bits image#
Although raw images store data using a 16-bit integer, the actual data typically uses 12-bit. Saving an image with a 12-bit bit depth can reduce storage requirements while preserving image quality.
#include "P1Image.hpp"
#include <iostream>
using namespace P1::ImageSdk;
int main()
{
try
{
// 1. Load IIQ image
RawImage im("Sample.IIQ");
// 2. Convert
ConvertConfig config;
// Use at least 12-bit bitmap
config.SetOutputFormat(BitmapFormat::Rgb48);
BitmapImage bmp = im.Convert(config);
// 3. Export to Tiff
TiffConfig tiffConfig;
tiffConfig.commonConfig.outputBitDepth = BitDepth::U12;
TiffWriter("out.tiff", bmp, im, tiffConfig);
return 0;
}
catch (const std::exception& e)
{
std::cerr << e.what();
return -1;
}
}
using P1.ImageSdk;
// 1. Load IIQ image
RawImage im = new("Sample.IIQ");
// 2. Convert
ConvertConfig config = new();
// use at least 12-bit bitmap
config.SetOutputFormat(BitmapFormat.Rgb48);
IBitmapImage bmp = im.Convert(config);
// 4. Export to Tiff
TiffConfig tiffConfig = new();
tiffConfig.commonConfig.outputBitDepth = BitDepth.U12;
im.WriteAsTiff("out.tiff", bmp, tiffConfig);
Note
Both JPEG, JPEG 2000 (JP2), and TIFF support 12-bit bit depth.