How do I force Image type in write?
Posted: 2015-02-05T13:48:10-07:00
I'm unable to find any useful, current information on forcing the Image type when I save a file, via write("filename"). My output file is being color-optimized, but I don't want it to be.
Here's a short example:
Tile.png is a 16-bit-per-channel RGB file. Unfortunately, Test1.png ends up being 8-bit indexed color. I assume this is due to automatic optimization, since if I only modify one channel (say, red), the image has enough colors remaining that Test1.png is saved as 16-bit-per-channel RGB.
I need Test1.png to always have the exact same format as Tile.png.
I've tried adding pImage->type(TrueColorType) and pImage->depth(16), but they have no apparent effect. The library is compiled for 16-bit channels, x64, Visual Studio 2012.
Any thoughts or comments welcome.
Here's a short example:
Code: Select all
Image *pImage = new Image("d:\\temp\\Tile.png");
Pixels *pCache = new Pixels(*pImage);
PixelPacket *pPixels = pCache->get(0, 0, TILE_SIZE, TILE_SIZE);
pImage->modifyImage();
PixelPacket *pDst = pPixels;
for(int i=0; i<TILE_SIZE * TILE_SIZE; i++) {
pDst->red = QuantumRange;
pDst->green = 0;
pDst->blue = 0;
pDst++;
}
pCache->sync();
pImage->write("d:\\temp\\Test1.png");
SAFE_DELETE(pCache);
SAFE_DELETE(pImage);
I need Test1.png to always have the exact same format as Tile.png.
I've tried adding pImage->type(TrueColorType) and pImage->depth(16), but they have no apparent effect. The library is compiled for 16-bit channels, x64, Visual Studio 2012.
Any thoughts or comments welcome.