20#ifndef _KIS_TIFF_READER_H_
21#define _KIS_TIFF_READER_H_
33#include <kis_paint_device.h>
36#include "kis_global.h"
39#include <kis_iterator.h>
40#include <kis_paint_device.h>
42#define TQ_UINT32_MAX 4294967295u
46class KisTIFFPostProcessor {
48 KisTIFFPostProcessor(uint8 nbcolorssamples) : m_nbcolorssamples(nbcolorssamples) { }
50 virtual void postProcess8bit( TQ_UINT8* ) { };
51 virtual void postProcess16bit( TQ_UINT16* ) { };
52 virtual void postProcess32bit( TQ_UINT32* ) { };
54 inline uint8 nbColorsSamples() {
return m_nbcolorssamples; }
56 uint8 m_nbcolorssamples;
59class KisTIFFPostProcessorInvert :
public KisTIFFPostProcessor {
61 KisTIFFPostProcessorInvert(uint8 nbcolorssamples) : KisTIFFPostProcessor(nbcolorssamples) {}
63 virtual void postProcess8bit( TQ_UINT8* data )
65 for(
int i = 0; i < nbColorsSamples(); i++)
67 data[i] = TQ_UINT8_MAX - data[i];
70 virtual void postProcess16bit( TQ_UINT16* data )
72 TQ_UINT16* d = (TQ_UINT16*) data;
73 for(
int i = 0; i < nbColorsSamples(); i++)
75 d[i] = TQ_UINT16_MAX - d[i];
78 virtual void postProcess32bit( TQ_UINT32* data )
80 TQ_UINT32* d = (TQ_UINT32*) data;
81 for(
int i = 0; i < nbColorsSamples(); i++)
83 d[i] = TQ_UINT32_MAX - d[i];
88class KisTIFFPostProcessorICCLABtoCIELAB :
public KisTIFFPostProcessor {
90 KisTIFFPostProcessorICCLABtoCIELAB(uint8 nbcolorssamples) : KisTIFFPostProcessor(nbcolorssamples) {}
92 void postProcess8bit(TQ_UINT8* data)
94 TQ_INT8* ds = (TQ_INT8*) data;
95 for(
int i = 1; i < nbColorsSamples(); i++)
97 ds[i] = data[i] - TQ_UINT8_MAX/2;
100 void postProcess16bit(TQ_UINT16* data)
102 TQ_UINT16* d = (TQ_UINT16*) data;
103 TQ_INT16* ds = (TQ_INT16*) data;
104 for(
int i = 1; i < nbColorsSamples(); i++)
106 ds[i] = d[i] - TQ_UINT16_MAX /2;
109 void postProcess32bit(TQ_UINT32* data)
111 TQ_UINT32* d = (TQ_UINT32*) data;
112 TQ_INT32* ds = (TQ_INT32*) data;
113 for(
int i = 1; i < nbColorsSamples(); i++)
115 ds[i] = d[i] - TQ_UINT32_MAX /2;
121class KisTIFFReaderBase {
123 KisTIFFReaderBase( KisPaintDeviceSP device, TQ_UINT8* poses, int8 alphapos, uint8 sourceDepth, uint8 nbcolorssamples, uint8 extrasamplescount, cmsHTRANSFORM transformProfile, KisTIFFPostProcessor* postprocessor) : m_device(device), m_alphapos(alphapos), m_sourceDepth(sourceDepth), m_nbcolorssamples(nbcolorssamples), m_nbextrasamples(extrasamplescount), m_poses(poses), m_transformProfile(transformProfile), m_postprocess(postprocessor)
137 virtual uint copyDataToChannels( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 dataWidth, TIFFStreamBase* tiffstream) =0;
141 virtual void finalize() { };
143 inline KisPaintDeviceSP paintDevice() {
return m_device; }
144 inline TQ_UINT8 alphaPos() {
return m_alphapos; }
145 inline TQ_UINT8 sourceDepth() {
return m_sourceDepth; }
146 inline TQ_UINT8 nbColorsSamples() {
return m_nbcolorssamples; }
147 inline TQ_UINT8 nbExtraSamples() {
return m_nbextrasamples; }
148 inline TQ_UINT8* poses() {
return m_poses; }
149 inline cmsHTRANSFORM transform() {
return m_transformProfile; }
150 inline KisTIFFPostProcessor* postProcessor() {
return m_postprocess; }
152 KisPaintDeviceSP m_device;
154 TQ_UINT8 m_sourceDepth;
155 TQ_UINT8 m_nbcolorssamples;
156 TQ_UINT8 m_nbextrasamples;
158 cmsHTRANSFORM m_transformProfile;
159 KisTIFFPostProcessor* m_postprocess;
160 TQ_UINT32 m_tiffDataWidth;
163class KisTIFFReaderTarget8bit :
public KisTIFFReaderBase {
165 KisTIFFReaderTarget8bit( KisPaintDeviceSP device, TQ_UINT8* poses, int8 alphapos, uint8 sourceDepth, uint8 nbcolorssamples, uint8 extrasamplescount, cmsHTRANSFORM transformProfile, KisTIFFPostProcessor* postprocessor) : KisTIFFReaderBase(device, poses, alphapos, sourceDepth, nbcolorssamples, extrasamplescount, transformProfile, postprocessor )
170 virtual uint copyDataToChannels( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 dataWidth, TIFFStreamBase* tiffstream);
174class KisTIFFReaderTarget16bit :
public KisTIFFReaderBase {
176 KisTIFFReaderTarget16bit( KisPaintDeviceSP device, TQ_UINT8* poses, int8 alphapos, uint8 sourceDepth, uint8 nbcolorssamples, uint8 extrasamplescount, cmsHTRANSFORM transformProfile, KisTIFFPostProcessor* postprocessor) : KisTIFFReaderBase(device, poses, alphapos, sourceDepth, nbcolorssamples, extrasamplescount, transformProfile, postprocessor )
181 virtual uint copyDataToChannels( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 dataWidth, TIFFStreamBase* tiffstream) ;
184class KisTIFFReaderTarget32bit :
public KisTIFFReaderBase {
186 KisTIFFReaderTarget32bit( KisPaintDeviceSP device, TQ_UINT8* poses, int8 alphapos, uint8 sourceDepth, uint8 nbcolorssamples, uint8 extrasamplescount, cmsHTRANSFORM transformProfile, KisTIFFPostProcessor* postprocessor) : KisTIFFReaderBase(device, poses, alphapos, sourceDepth, nbcolorssamples, extrasamplescount, transformProfile, postprocessor )
191 virtual uint copyDataToChannels( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 dataWidth, TIFFStreamBase* tiffstream) ;
194class KisTIFFReaderFromPalette :
public KisTIFFReaderBase {
196 KisTIFFReaderFromPalette( KisPaintDeviceSP device, uint16 *red, uint16 *green, uint16 *blue, TQ_UINT8* poses, int8 alphapos, uint8 sourceDepth, uint8 nbcolorssamples, uint8 extrasamplescount, cmsHTRANSFORM transformProfile, KisTIFFPostProcessor* postprocessor) : KisTIFFReaderBase(device, poses, alphapos, sourceDepth, nbcolorssamples, extrasamplescount, transformProfile, postprocessor ), m_red(red), m_green(green), m_blue(blue)
201 virtual uint copyDataToChannels( TQ_UINT32 x, TQ_UINT32 y, TQ_UINT32 dataWidth, TIFFStreamBase* tiffstream) ;
203 uint16 *m_red, *m_green, *m_blue;