00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "kis_tiff_reader.h"
00021
00022 #include <kdebug.h>
00023
00024 #include <kis_iterators_pixel.h>
00025 #include <kis_paint_device.h>
00026
00027 #include "kis_tiff_stream.h"
00028
00029 uint KisTIFFReaderTarget8bit::copyDataToChannels( Q_UINT32 x, Q_UINT32 y, Q_UINT32 dataWidth, TIFFStreamBase* tiffstream)
00030 {
00031 KisHLineIterator it = paintDevice() -> createHLineIterator(x, y, dataWidth, true);
00032 double coeff = Q_UINT8_MAX / (double)( pow(2, sourceDepth() ) - 1 );
00033
00034 while (!it.isDone()) {
00035 Q_UINT8 *d = it.rawData();
00036 Q_UINT8 i;
00037 for(i = 0; i < nbColorsSamples() ; i++)
00038 {
00039 d[poses()[i]] = (Q_UINT8)( tiffstream->nextValue() * coeff );
00040 }
00041 postProcessor()->postProcess8bit( d);
00042 if(transform()) cmsDoTransform(transform(), d, d, 1);
00043 d[poses()[i]] = Q_UINT8_MAX;
00044 for(int k = 0; k < nbExtraSamples(); k++)
00045 {
00046 if(k == alphaPos())
00047 d[poses()[i]] = (Q_UINT32) ( tiffstream->nextValue() * coeff );
00048 else
00049 tiffstream->nextValue();
00050 }
00051 ++it;
00052 }
00053 return 1;
00054 }
00055 uint KisTIFFReaderTarget16bit::copyDataToChannels( Q_UINT32 x, Q_UINT32 y, Q_UINT32 dataWidth, TIFFStreamBase* tiffstream)
00056 {
00057 KisHLineIterator it = paintDevice() -> createHLineIterator(x, y, dataWidth, true);
00058 double coeff = Q_UINT16_MAX / (double)( pow(2, sourceDepth() ) - 1 );
00059
00060 while (!it.isDone()) {
00061 Q_UINT16 *d = reinterpret_cast<Q_UINT16 *>(it.rawData());
00062 Q_UINT8 i;
00063 for(i = 0; i < nbColorsSamples(); i++)
00064 {
00065 d[poses()[i]] = (Q_UINT16)( tiffstream->nextValue() * coeff );
00066 }
00067 postProcessor()->postProcess16bit( d);
00068 if(transform()) cmsDoTransform(transform(), d, d, 1);
00069 d[poses()[i]] = Q_UINT16_MAX;
00070 for(int k = 0; k < nbExtraSamples(); k++)
00071 {
00072 if(k == alphaPos())
00073 d[poses()[i]] = (Q_UINT16) ( tiffstream->nextValue() * coeff );
00074 else
00075 tiffstream->nextValue();
00076 }
00077 ++it;
00078 }
00079 return 1;
00080 }
00081
00082 uint KisTIFFReaderTarget32bit::copyDataToChannels( Q_UINT32 x, Q_UINT32 y, Q_UINT32 dataWidth, TIFFStreamBase* tiffstream)
00083 {
00084 KisHLineIterator it = paintDevice() -> createHLineIterator(x, y, dataWidth, true);
00085 double coeff = Q_UINT32_MAX / (double)( pow(2, sourceDepth() ) - 1 );
00086
00087 while (!it.isDone()) {
00088 Q_UINT32 *d = reinterpret_cast<Q_UINT32 *>(it.rawData());
00089 Q_UINT8 i;
00090 for(i = 0; i < nbColorsSamples(); i++)
00091 {
00092 d[poses()[i]] = (Q_UINT32)( tiffstream->nextValue() * coeff );
00093 }
00094 postProcessor()->postProcess32bit( d);
00095 if(transform()) cmsDoTransform(transform(), d, d, 1);
00096 d[poses()[i]] = Q_UINT32_MAX;
00097 for(int k = 0; k < nbExtraSamples(); k++)
00098 {
00099 if(k == alphaPos())
00100 d[poses()[i]] = (Q_UINT32) ( tiffstream->nextValue() * coeff );
00101 else
00102 tiffstream->nextValue();
00103 }
00104 ++it;
00105 }
00106 return 1;
00107 }
00108 uint KisTIFFReaderFromPalette::copyDataToChannels(Q_UINT32 x, Q_UINT32 y, Q_UINT32 dataWidth, TIFFStreamBase* tiffstream)
00109 {
00110 KisHLineIterator it = paintDevice() -> createHLineIterator(x, y, dataWidth, true);
00111 while (!it.isDone()) {
00112 Q_UINT16* d = reinterpret_cast<Q_UINT16 *>(it.rawData());
00113 uint32 index = tiffstream->nextValue();
00114 d[2] = m_red[index];
00115 d[1] = m_green[index];
00116 d[0] = m_blue[index];
00117 d[3] = Q_UINT16_MAX;
00118 ++it;
00119 }
00120 return 1;
00121 }