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; }
RawImage PefDecoder::decodeRawInternal() { auto raw = mRootIFD->getIFDWithTag(STRIPOFFSETS); int compression = raw->getEntry(COMPRESSION)->getU32(); if (1 == compression || compression == 32773) { decodeUncompressed(raw, BitOrder_MSB); return mRaw; } if (65535 != compression) ThrowRDE("Unsupported compression"); TiffEntry *offsets = raw->getEntry(STRIPOFFSETS); TiffEntry *counts = raw->getEntry(STRIPBYTECOUNTS); if (offsets->count != 1) { ThrowRDE("Multiple Strips found: %u", offsets->count); } if (counts->count != offsets->count) { ThrowRDE( "Byte count number does not match strip size: count:%u, strips:%u ", counts->count, offsets->count); } if (!mFile->isValid(offsets->getU32(), counts->getU32())) ThrowRDE("Truncated file."); uint32 width = raw->getEntry(IMAGEWIDTH)->getU32(); uint32 height = raw->getEntry(IMAGELENGTH)->getU32(); mRaw->dim = iPoint2D(width, height); mRaw->createData(); try { PentaxDecompressor::decompress( mRaw, ByteStream(mFile, offsets->getU32(), counts->getU32()), getRootIFD()); } catch (IOException &e) { mRaw->setError(e.what()); // Let's ignore it, it may have delivered somewhat useful data. } return mRaw; }