本文整理汇总了C++中TiffIFD::getEntry方法的典型用法代码示例。如果您正苦于以下问题:C++ TiffIFD::getEntry方法的具体用法?C++ TiffIFD::getEntry怎么用?C++ TiffIFD::getEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiffIFD
的用法示例。
在下文中一共展示了TiffIFD::getEntry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getMode
string NefDecoder::getMode() {
ostringstream mode;
vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(CFAPATTERN);
TiffIFD* raw = FindBestImage(&data);
int compression = raw->getEntry(COMPRESSION)->getInt();
uint32 bitPerPixel = raw->getEntry(BITSPERSAMPLE)->getInt();
if (1 == compression)
mode << bitPerPixel << "bit-uncompressed";
else
mode << bitPerPixel << "bit-uncompressed";
return mode.str();
}
示例2: decodeRawInternal
RawImage PefDecoder::decodeRawInternal() {
vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(STRIPOFFSETS);
if (data.empty())
ThrowRDE("PEF Decoder: No image data found");
TiffIFD* raw = data[0];
int compression = raw->getEntry(COMPRESSION)->getInt();
if (1 == compression) {
decodeUncompressed(raw, true);
return mRaw;
}
if (65535 != compression)
ThrowRDE("PEF Decoder: Unsupported compression");
TiffEntry *offsets = raw->getEntry(STRIPOFFSETS);
TiffEntry *counts = raw->getEntry(STRIPBYTECOUNTS);
if (offsets->count != 1) {
ThrowRDE("PEF Decoder: Multiple Strips found: %u", offsets->count);
}
if (counts->count != offsets->count) {
ThrowRDE("PEF Decoder: Byte count number does not match strip size: count:%u, strips:%u ", counts->count, offsets->count);
}
if (!mFile->isValid(offsets->getInt() + counts->getInt()))
ThrowRDE("PEF Decoder: Truncated file.");
uint32 width = raw->getEntry(IMAGEWIDTH)->getInt();
uint32 height = raw->getEntry(IMAGELENGTH)->getInt();
mRaw->dim = iPoint2D(width, height);
mRaw->createData();
try {
PentaxDecompressor l(mFile, mRaw);
l.decodePentax(mRootIFD, offsets->getInt(), counts->getInt());
} catch (IOException &e) {
errors.push_back(_strdup(e.what()));
// Let's ignore it, it may have delivered somewhat useful data.
}
return mRaw;
}
示例3: decodeMetaData
void PefDecoder::decodeMetaData(CameraMetaData *meta) {
int iso = 0;
mRaw->cfa.setCFA(CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE);
vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
if (data.empty())
ThrowRDE("PEF Meta Decoder: Model name found");
TiffIFD* raw = data[0];
string make = raw->getEntry(MAKE)->getString();
string model = raw->getEntry(MODEL)->getString();
if (mRootIFD->hasEntryRecursive(ISOSPEEDRATINGS))
iso = mRootIFD->getEntryRecursive(ISOSPEEDRATINGS)->getInt();
setMetaData(meta, make, model, "", iso);
}
示例4: decodeRawInternal
RawImage ThreefrDecoder::decodeRawInternal() {
vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(STRIPOFFSETS);
if (data.size() < 2)
ThrowRDE("3FR Decoder: No image data found");
TiffIFD* raw = data[1];
uint32 width = raw->getEntry(IMAGEWIDTH)->getInt();
uint32 height = raw->getEntry(IMAGELENGTH)->getInt();
uint32 off = raw->getEntry(STRIPOFFSETS)->getInt();
mRaw->dim = iPoint2D(width, height);
mRaw->createData();
ByteStream input(mFile->getData(off), mFile->getSize() - off);
HasselbladDecompressor l(mFile, mRaw);
map<string,string>::iterator pixelOffset = hints.find("pixelBaseOffset");
if (pixelOffset != hints.end()) {
stringstream convert((*pixelOffset).second);
convert >> l.pixelBaseOffset;
}
示例5: FindBestImage
TiffIFD* NefDecoder::FindBestImage(vector<TiffIFD*>* data) {
int largest_width = 0;
TiffIFD* best_ifd = NULL;
for (int i = 0; i < (int)data->size(); i++) {
TiffIFD* raw = (*data)[i];
int width = raw->getEntry(IMAGEWIDTH)->getInt();
if (width > largest_width)
best_ifd = raw;
}
if (NULL == best_ifd)
ThrowRDE("NEF Decoder: Unable to locate image");
return best_ifd;
}
示例6: decodeMetaDataInternal
void PefDecoder::decodeMetaDataInternal(CameraMetaData *meta) {
int iso = 0;
mRaw->cfa.setCFA(iPoint2D(2,2), CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE);
vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
if (data.empty())
ThrowRDE("PEF Meta Decoder: Model name found");
TiffIFD* raw = data[0];
string make = raw->getEntry(MAKE)->getString();
string model = raw->getEntry(MODEL)->getString();
if (mRootIFD->hasEntryRecursive(ISOSPEEDRATINGS))
iso = mRootIFD->getEntryRecursive(ISOSPEEDRATINGS)->getInt();
setMetaData(meta, make, model, "", iso);
// Read black level
if (mRootIFD->hasEntryRecursive((TiffTag)0x200)) {
TiffEntry *black = mRootIFD->getEntryRecursive((TiffTag)0x200);
const ushort16 *levels = black->getShortArray();
for (int i = 0; i < 4; i++)
mRaw->blackLevelSeparate[i] = levels[i];
}
// Set the whitebalance
if (mRootIFD->hasEntryRecursive((TiffTag) 0x0201)) {
TiffEntry *wb = mRootIFD->getEntryRecursive((TiffTag) 0x0201);
if (wb->count == 4) {
const ushort16 *tmp = wb->getShortArray();
mRaw->metadata.wbCoeffs[0] = tmp[0];
mRaw->metadata.wbCoeffs[1] = tmp[1];
mRaw->metadata.wbCoeffs[2] = tmp[3];
}
}
}
示例7: decodeRawInternal
RawImage SrwDecoder::decodeRawInternal() {
vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(STRIPOFFSETS);
if (data.empty())
ThrowRDE("Srw Decoder: No image data found");
TiffIFD* raw = data[0];
int compression = raw->getEntry(COMPRESSION)->getInt();
int bits = raw->getEntry(BITSPERSAMPLE)->getInt();
if (32769 != compression && 32770 != compression )
ThrowRDE("Srw Decoder: Unsupported compression");
if (32769 == compression)
{
bool bit_order = false; // Default guess
map<string,string>::iterator msb_hint = hints.find("msb_override");
if (msb_hint != hints.end())
bit_order = (0 == (msb_hint->second).compare("true"));
this->decodeUncompressed(raw, bit_order ? BitOrder_Jpeg : BitOrder_Plain);
return mRaw;
}
if (32770 == compression)
{
bool bit_order = (bits == 12); // Default guess
map<string,string>::iterator msb_hint = hints.find("msb_override");
if (msb_hint != hints.end())
bit_order = (0 == (msb_hint->second).compare("true"));
this->decodeUncompressed(raw, bit_order ? BitOrder_Jpeg : BitOrder_Plain);
return mRaw;
}
ThrowRDE("Srw Decoder: Unsupported compression");
return mRaw;
}
示例8: DecodeUncompressed
void NefDecoder::DecodeUncompressed() {
vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(CFAPATTERN);
TiffIFD* raw = FindBestImage(&data);
uint32 nslices = raw->getEntry(STRIPOFFSETS)->count;
const uint32 *offsets = raw->getEntry(STRIPOFFSETS)->getIntArray();
const uint32 *counts = raw->getEntry(STRIPBYTECOUNTS)->getIntArray();
uint32 yPerSlice = raw->getEntry(ROWSPERSTRIP)->getInt();
uint32 width = raw->getEntry(IMAGEWIDTH)->getInt();
uint32 height = raw->getEntry(IMAGELENGTH)->getInt();
uint32 bitPerPixel = raw->getEntry(BITSPERSAMPLE)->getInt();
vector<NefSlice> slices;
uint32 offY = 0;
for (uint32 s = 0; s < nslices; s++) {
NefSlice slice;
slice.offset = offsets[s];
slice.count = counts[s];
if (offY + yPerSlice > height)
slice.h = height - offY;
else
slice.h = yPerSlice;
offY = MIN(height, offY + yPerSlice);
if (mFile->isValid(slice.offset, slice.count)) // Only decode if size is valid
slices.push_back(slice);
}
if (0 == slices.size())
ThrowRDE("NEF Decoder: No valid slices found. File probably truncated.");
mRaw->dim = iPoint2D(width, offY);
mRaw->createData();
if (bitPerPixel == 14 && width*slices[0].h*2 == slices[0].count)
bitPerPixel = 16; // D3 & D810
if(hints.find("real_bpp") != hints.end()) {
stringstream convert(hints.find("real_bpp")->second);
convert >> bitPerPixel;
}
示例9: ThrowRDE
void Cr2Decoder::checkSupportInternal(CameraMetaData *meta) {
vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
if (data.empty())
ThrowRDE("CR2 Support check: Model name not found");
if (!data[0]->hasEntry(MAKE))
ThrowRDE("CR2 Support: Make name not found");
string make = data[0]->getEntry(MAKE)->getString();
string model = data[0]->getEntry(MODEL)->getString();
// Check for sRaw mode
data = mRootIFD->getIFDsWithTag((TiffTag)0xc5d8);
if (!data.empty()) {
TiffIFD* raw = data[0];
if (raw->hasEntry((TiffTag)0xc6c5)) {
ushort16 ss = raw->getEntry((TiffTag)0xc6c5)->getInt();
if (ss == 4) {
this->checkCameraSupported(meta, make, model, "sRaw1");
return;
}
}
}
this->checkCameraSupported(meta, make, model, "");
}
示例10: getDecoder
RawDecoder* TiffParser::getDecoder() {
if (!mRootIFD)
parseData();
vector<TiffIFD*> potentials;
potentials = mRootIFD->getIFDsWithTag(DNGVERSION);
/* Copy, so we can pass it on and not have it destroyed with ourselves */
TiffIFD* root = mRootIFD;
if (!potentials.empty()) { // We have a dng image entry
TiffIFD *t = potentials[0];
const unsigned char* c = t->getEntry(DNGVERSION)->getData();
if (c[0] > 1)
throw TiffParserException("DNG version too new.");
mRootIFD = NULL;
return new DngDecoder(root, mInput);
}
potentials = mRootIFD->getIFDsWithTag(MAKE);
if (!potentials.empty()) { // We have make entry
for (vector<TiffIFD*>::iterator i = potentials.begin(); i != potentials.end(); ++i) {
string make = (*i)->getEntry(MAKE)->getString();
TrimSpaces(make);
string model = "";
if ((*i)->hasEntry(MODEL)) {
model = (*i)->getEntry(MODEL)->getString();
TrimSpaces(model);
}
if (!make.compare("Canon")) {
mRootIFD = NULL;
return new Cr2Decoder(root, mInput);
}
if (!make.compare("FUJIFILM")) {
mRootIFD = NULL;
return new RafDecoder(root, mInput);
}
if (!make.compare("NIKON CORPORATION")) {
mRootIFD = NULL;
return new NefDecoder(root, mInput);
}
if (!make.compare("NIKON")) {
mRootIFD = NULL;
return new NefDecoder(root, mInput);
}
if (!make.compare("OLYMPUS IMAGING CORP.") ||
!make.compare("OLYMPUS CORPORATION") ||
!make.compare("OLYMPUS OPTICAL CO.,LTD") ) {
mRootIFD = NULL;
return new OrfDecoder(root, mInput);
}
if (!make.compare("SONY")) {
mRootIFD = NULL;
return new ArwDecoder(root, mInput);
}
if (!make.compare("PENTAX Corporation") || !make.compare("RICOH IMAGING COMPANY, LTD.")) {
mRootIFD = NULL;
return new PefDecoder(root, mInput);
}
if (!make.compare("PENTAX")) {
mRootIFD = NULL;
return new PefDecoder(root, mInput);
}
if (!make.compare("Panasonic") || !make.compare("LEICA")) {
mRootIFD = NULL;
return new Rw2Decoder(root, mInput);
}
if (!make.compare("SAMSUNG")) {
mRootIFD = NULL;
return new SrwDecoder(root, mInput);
}
if (!make.compare("Mamiya-OP Co.,Ltd.")) {
mRootIFD = NULL;
return new MefDecoder(root, mInput);
}
if (!make.compare("Kodak")) {
mRootIFD = NULL;
if (!model.compare("DCS560C"))
return new Cr2Decoder(root, mInput);
else
return new DcrDecoder(root, mInput);
}
if (!make.compare("KODAK")) {
mRootIFD = NULL;
return new DcsDecoder(root, mInput);
}
if (!make.compare("EASTMAN KODAK COMPANY")) {
mRootIFD = NULL;
return new KdcDecoder(root, mInput);
}
if (!make.compare("SEIKO EPSON CORP.")) {
mRootIFD = NULL;
return new ErfDecoder(root, mInput);
}
if (!make.compare("Hasselblad")) {
mRootIFD = NULL;
return new ThreefrDecoder(root, mInput);
}
if (!make.compare("Leaf")) {
//.........这里部分代码省略.........
示例11: final_size
RawImage Cr2Decoder::decodeRawInternal() {
if(hints.find("old_format") != hints.end()) {
uint32 off = 0;
if (mRootIFD->getEntryRecursive((TiffTag)0x81))
off = mRootIFD->getEntryRecursive((TiffTag)0x81)->getInt();
else {
vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(CFAPATTERN);
if (data.empty())
ThrowRDE("CR2 Decoder: Couldn't find offset");
else {
if (data[0]->hasEntry(STRIPOFFSETS))
off = data[0]->getEntry(STRIPOFFSETS)->getInt();
else
ThrowRDE("CR2 Decoder: Couldn't find offset");
}
}
ByteStream *b;
if (getHostEndianness() == big)
b = new ByteStream(mFile, off+41);
else
b = new ByteStreamSwap(mFile, off+41);
uint32 height = b->getShort();
uint32 width = b->getShort();
// Every two lines can be encoded as a single line, probably to try and get
// better compression by getting the same RGBG sequence in every line
if(hints.find("double_line_ljpeg") != hints.end()) {
height *= 2;
mRaw->dim = iPoint2D(width*2, height/2);
}
else {
width *= 2;
mRaw->dim = iPoint2D(width, height);
}
mRaw->createData();
LJpegPlain *l = new LJpegPlain(mFile, mRaw);
try {
l->startDecoder(off, mFile->getSize()-off, 0, 0);
} catch (IOException& e) {
mRaw->setError(e.what());
}
delete l;
if(hints.find("double_line_ljpeg") != hints.end()) {
// We now have a double width half height image we need to convert to the
// normal format
iPoint2D final_size(width, height);
RawImage procRaw = RawImage::create(final_size, TYPE_USHORT16, 1);
procRaw->metadata = mRaw->metadata;
procRaw->copyErrorsFrom(mRaw);
for (uint32 y = 0; y < height; y++) {
ushort16 *dst = (ushort16*)procRaw->getData(0,y);
ushort16 *src = (ushort16*)mRaw->getData(y%2 == 0 ? 0 : width, y/2);
for (uint32 x = 0; x < width; x++)
dst[x] = src[x];
}
mRaw = procRaw;
}
if (mRootIFD->getEntryRecursive((TiffTag)0x123)) {
TiffEntry *curve = mRootIFD->getEntryRecursive((TiffTag)0x123);
if (curve->type == TIFF_SHORT && curve->count == 4096) {
TiffEntry *linearization = mRootIFD->getEntryRecursive((TiffTag)0x123);
uint32 len = linearization->count;
ushort16 *table = new ushort16[len];
linearization->getShortArray(table, len);
if (!uncorrectedRawValues) {
mRaw->setTable(table, 4096, true);
// Apply table
mRaw->sixteenBitLookup();
// Delete table
mRaw->setTable(NULL);
} else {
// We want uncorrected, but we store the table.
mRaw->setTable(table, 4096, false);
}
}
}
return mRaw;
}
vector<TiffIFD*> data = mRootIFD->getIFDsWithTag((TiffTag)0xc5d8);
if (data.empty())
ThrowRDE("CR2 Decoder: No image data found");
TiffIFD* raw = data[0];
mRaw = RawImage::create();
mRaw->isCFA = true;
vector<Cr2Slice> slices;
int completeH = 0;
bool doubleHeight = false;
try {
//.........这里部分代码省略.........
示例12: decodeRawInternal
RawImage NefDecoder::decodeRawInternal() {
vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(CFAPATTERN);
if (data.empty())
ThrowRDE("NEF Decoder: No image data found");
TiffIFD* raw = data[0];
int compression = raw->getEntry(COMPRESSION)->getInt();
data = mRootIFD->getIFDsWithTag(MODEL);
if (data.empty())
ThrowRDE("NEF Decoder: No model data found");
TiffEntry *offsets = raw->getEntry(STRIPOFFSETS);
TiffEntry *counts = raw->getEntry(STRIPBYTECOUNTS);
if (!data[0]->getEntry(MODEL)->getString().compare("NIKON D100 ")) { /**Sigh**/
if (!mFile->isValid(offsets->getInt()))
ThrowRDE("NEF Decoder: Image data outside of file.");
if (!D100IsCompressed(offsets->getInt())) {
DecodeD100Uncompressed();
return mRaw;
}
}
if (compression == 1) {
DecodeUncompressed();
return mRaw;
}
if (offsets->count != 1) {
ThrowRDE("NEF Decoder: Multiple Strips found: %u", offsets->count);
}
if (counts->count != offsets->count) {
ThrowRDE("NEF Decoder: Byte count number does not match strip size: count:%u, strips:%u ", counts->count, offsets->count);
}
if (!mFile->isValid(offsets->getInt() + counts->getInt()))
ThrowRDE("NEF Decoder: Invalid strip byte count. File probably truncated.");
if (34713 != compression)
ThrowRDE("NEF Decoder: Unsupported compression");
uint32 width = raw->getEntry(IMAGEWIDTH)->getInt();
uint32 height = raw->getEntry(IMAGELENGTH)->getInt();
uint32 bitPerPixel = raw->getEntry(BITSPERSAMPLE)->getInt();
mRaw->dim = iPoint2D(width, height);
mRaw->createData();
data = mRootIFD->getIFDsWithTag(MAKERNOTE);
if (data.empty())
ThrowRDE("NEF Decoder: No EXIF data found");
TiffIFD* exif = data[0];
TiffEntry *makernoteEntry = exif->getEntry(MAKERNOTE);
const uchar8* makernote = makernoteEntry->getData();
FileMap makermap((uchar8*)&makernote[10], mFile->getSize() - makernoteEntry->getDataOffset() - 10);
TiffParser makertiff(&makermap);
makertiff.parseData();
data = makertiff.RootIFD()->getIFDsWithTag((TiffTag)0x8c);
if (data.empty())
ThrowRDE("NEF Decoder: Decompression info tag not found");
TiffEntry *meta;
try {
meta = data[0]->getEntry((TiffTag)0x96);
} catch (TiffParserException) {
meta = data[0]->getEntry((TiffTag)0x8c); // Fall back
}
try {
NikonDecompressor decompressor(mFile, mRaw);
ByteStream* metastream;
if (getHostEndianness() == data[0]->endian)
metastream = new ByteStream(meta->getData(), meta->count);
else
metastream = new ByteStreamSwap(meta->getData(), meta->count);
decompressor.DecompressNikon(metastream, width, height, bitPerPixel, offsets->getInt(), counts->getInt());
delete metastream;
} catch (IOException &e) {
mRaw->setError(e.what());
// Let's ignore it, it may have delivered somewhat useful data.
}
return mRaw;
}
示例13: DecodeUncompressed
void NefDecoder::DecodeUncompressed() {
vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(CFAPATTERN);
TiffIFD* raw = FindBestImage(&data);
uint32 nslices = raw->getEntry(STRIPOFFSETS)->count;
const uint32 *offsets = raw->getEntry(STRIPOFFSETS)->getIntArray();
const uint32 *counts = raw->getEntry(STRIPBYTECOUNTS)->getIntArray();
uint32 yPerSlice = raw->getEntry(ROWSPERSTRIP)->getInt();
uint32 width = raw->getEntry(IMAGEWIDTH)->getInt();
uint32 height = raw->getEntry(IMAGELENGTH)->getInt();
uint32 bitPerPixel = raw->getEntry(BITSPERSAMPLE)->getInt();
vector<NefSlice> slices;
uint32 offY = 0;
for (uint32 s = 0; s < nslices; s++) {
NefSlice slice;
slice.offset = offsets[s];
slice.count = counts[s];
if (offY + yPerSlice > height)
slice.h = height - offY;
else
slice.h = yPerSlice;
offY += yPerSlice;
if (mFile->isValid(slice.offset + slice.count)) // Only decode if size is valid
slices.push_back(slice);
}
if (0 == slices.size())
ThrowRDE("NEF Decoder: No valid slices found. File probably truncated.");
mRaw->dim = iPoint2D(width, offY);
mRaw->createData();
if (bitPerPixel == 14 && width*slices[0].h*2 == slices[0].count)
bitPerPixel = 16; // D3
offY = 0;
for (uint32 i = 0; i < slices.size(); i++) {
NefSlice slice = slices[i];
ByteStream in(mFile->getData(slice.offset), slice.count);
iPoint2D size(width, slice.h);
iPoint2D pos(0, offY);
try {
if (hints.find(string("coolpixmangled")) != hints.end())
readCoolpixMangledRaw(in, size, pos, width*bitPerPixel / 8);
else if (hints.find(string("coolpixsplit")) != hints.end())
readCoolpixSplitRaw(in, size, pos, width*bitPerPixel / 8);
else
readUncompressedRaw(in, size, pos, width*bitPerPixel / 8, bitPerPixel, true);
} catch (RawDecoderException e) {
if (i>0)
mRaw->setError(e.what());
else
throw;
} catch (IOException e) {
if (i>0)
mRaw->setError(e.what());
else
ThrowRDE("NEF decoder: IO error occurred in first slice, unable to decode more. Error is: %s", e.what());
}
offY += slice.h;
}
}
示例14: decodeRawInternal
RawImage NefDecoder::decodeRawInternal() {
vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(CFAPATTERN);
if (data.empty())
ThrowRDE("NEF Decoder: No image data found");
TiffIFD* raw = data[0];
int compression = raw->getEntry(COMPRESSION)->getInt();
data = mRootIFD->getIFDsWithTag(MODEL);
if (data.empty())
ThrowRDE("NEF Decoder: No model data found");
TiffEntry *offsets = raw->getEntry(STRIPOFFSETS);
TiffEntry *counts = raw->getEntry(STRIPBYTECOUNTS);
if (!data[0]->getEntry(MODEL)->getString().compare("NIKON D100 ")) { /**Sigh**/
if (!mFile->isValid(offsets->getInt()))
ThrowRDE("NEF Decoder: Image data outside of file.");
if (!D100IsCompressed(offsets->getInt())) {
DecodeD100Uncompressed();
return mRaw;
}
}
if (compression == 1 || (hints.find(string("force_uncompressed")) != hints.end()) ||
NEFIsUncompressed(raw)) {
DecodeUncompressed();
return mRaw;
}
if (NEFIsUncompressedRGB(raw)) {
DecodeSNefUncompressed();
return mRaw;
}
if (offsets->count != 1) {
ThrowRDE("NEF Decoder: Multiple Strips found: %u", offsets->count);
}
if (counts->count != offsets->count) {
ThrowRDE("NEF Decoder: Byte count number does not match strip size: count:%u, strips:%u ", counts->count, offsets->count);
}
if (!mFile->isValid(offsets->getInt(), counts->getInt()))
ThrowRDE("NEF Decoder: Invalid strip byte count. File probably truncated.");
if (34713 != compression)
ThrowRDE("NEF Decoder: Unsupported compression");
uint32 width = raw->getEntry(IMAGEWIDTH)->getInt();
uint32 height = raw->getEntry(IMAGELENGTH)->getInt();
uint32 bitPerPixel = raw->getEntry(BITSPERSAMPLE)->getInt();
mRaw->dim = iPoint2D(width, height);
mRaw->createData();
data = mRootIFD->getIFDsWithTag((TiffTag)0x8c);
if (data.empty())
ThrowRDE("NEF Decoder: Decompression info tag not found");
TiffEntry *meta;
if (data[0]->hasEntry((TiffTag)0x96)) {
meta = data[0]->getEntry((TiffTag)0x96);
} else {
meta = data[0]->getEntry((TiffTag)0x8c); // Fall back
}
try {
NikonDecompressor decompressor(mFile, mRaw);
decompressor.uncorrectedRawValues = uncorrectedRawValues;
ByteStream* metastream;
if (getHostEndianness() == data[0]->endian)
metastream = new ByteStream(meta->getData(), meta->count);
else
metastream = new ByteStreamSwap(meta->getData(), meta->count);
decompressor.DecompressNikon(metastream, width, height, bitPerPixel, offsets->getInt(), counts->getInt());
delete metastream;
} catch (IOException &e) {
mRaw->setError(e.what());
// Let's ignore it, it may have delivered somewhat useful data.
}
return mRaw;
}
示例15: input_start
RawImage Rw2Decoder::decodeRawInternal() {
vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(PANASONIC_STRIPOFFSET);
bool isOldPanasonic = FALSE;
if (data.empty()) {
if (!mRootIFD->hasEntryRecursive(STRIPOFFSETS))
ThrowRDE("RW2 Decoder: No image data found");
isOldPanasonic = TRUE;
data = mRootIFD->getIFDsWithTag(STRIPOFFSETS);
}
TiffIFD* raw = data[0];
uint32 height = raw->getEntry((TiffTag)3)->getShort();
uint32 width = raw->getEntry((TiffTag)2)->getShort();
if (isOldPanasonic) {
ThrowRDE("Cannot decode old-style Panasonic RAW files");
TiffEntry *offsets = raw->getEntry(STRIPOFFSETS);
TiffEntry *counts = raw->getEntry(STRIPBYTECOUNTS);
if (offsets->count != 1) {
ThrowRDE("RW2 Decoder: Multiple Strips found: %u", offsets->count);
}
int off = offsets->getInt();
if (!mFile->isValid(off))
ThrowRDE("Panasonic RAW Decoder: Invalid image data offset, cannot decode.");
int count = counts->getInt();
if (count != (int)(width*height*2))
ThrowRDE("Panasonic RAW Decoder: Byte count is wrong.");
if (!mFile->isValid(off+count))
ThrowRDE("Panasonic RAW Decoder: Invalid image data offset, cannot decode.");
mRaw->dim = iPoint2D(width, height);
mRaw->createData();
ByteStream input_start(mFile->getData(off), mFile->getSize() - off);
iPoint2D pos(0, 0);
readUncompressedRaw(input_start, mRaw->dim,pos, width*2, 16, BitOrder_Plain);
} else {
mRaw->dim = iPoint2D(width, height);
mRaw->createData();
TiffEntry *offsets = raw->getEntry(PANASONIC_STRIPOFFSET);
if (offsets->count != 1) {
ThrowRDE("RW2 Decoder: Multiple Strips found: %u", offsets->count);
}
load_flags = 0x2008;
int off = offsets->getInt();
if (!mFile->isValid(off))
ThrowRDE("RW2 Decoder: Invalid image data offset, cannot decode.");
input_start = new ByteStream(mFile->getData(off), mFile->getSize() - off);
DecodeRw2();
}
// Read blacklevels
if (raw->hasEntry((TiffTag)0x1c) && raw->hasEntry((TiffTag)0x1d) && raw->hasEntry((TiffTag)0x1e)) {
mRaw->blackLevelSeparate[0] = raw->getEntry((TiffTag)0x1c)->getInt() + 15;
mRaw->blackLevelSeparate[1] = mRaw->blackLevelSeparate[2] = raw->getEntry((TiffTag)0x1d)->getInt() + 15;
mRaw->blackLevelSeparate[3] = raw->getEntry((TiffTag)0x1e)->getInt() + 15;
}
return mRaw;
}