filters
kis_tiff_reader.cc00001
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 KisTIFFReaderFromPalette::copyDataToChannels(Q_UINT32 x, Q_UINT32 y, Q_UINT32 dataWidth, TIFFStreamBase* tiffstream)
00083 {
00084 KisHLineIterator it = paintDevice() -> createHLineIterator(x, y, dataWidth, true);
00085 while (!it.isDone()) {
00086 Q_UINT16* d = reinterpret_cast<Q_UINT16 *>(it.rawData());
00087 uint32 index = tiffstream->nextValue();
00088 d[2] = m_red[index];
00089 d[1] = m_green[index];
00090 d[0] = m_blue[index];
00091 d[3] = Q_UINT16_MAX;
00092 ++it;
00093 }
00094 return 1;
00095 }
|