RawImage MrwDecoder::decodeRawInternal() { uint32 imgsize; mRaw->dim = iPoint2D(raw_width, raw_height); mRaw->createData(); if (packed) imgsize = raw_width * raw_height * 3 / 2; else imgsize = raw_width * raw_height * 2; if (!mFile->isValid(data_offset)) ThrowRDE("MRW decoder: Data offset after EOF, file probably truncated"); if (!mFile->isValid(data_offset+imgsize-1)) ThrowRDE("MRW decoder: Image end after EOF, file probably truncated"); ByteStream input(mFile->getData(data_offset), imgsize); try { if (packed) Decode12BitRawBE(input, raw_width, raw_height); else Decode12BitRawBEunpacked(input, raw_width, raw_height); } catch (IOException &e) { mRaw->setError(e.what()); // Let's ignore it, it may have delivered somewhat useful data. } return mRaw; }
RawImage KdcDecoder::decodeRawInternal() { int compression = mRootIFD->getEntryRecursive(COMPRESSION)->getInt(); if (7 != compression) ThrowRDE("KDC Decoder: Unsupported compression %d", compression); TiffEntry *ex = mRootIFD->getEntryRecursive(PIXELXDIMENSION); TiffEntry *ey = mRootIFD->getEntryRecursive(PIXELYDIMENSION); if (NULL == ex || NULL == ey) ThrowRDE("KDC Decoder: Unable to retrieve image size"); uint32 width = ex->getInt(); uint32 height = ey->getInt(); TiffEntry *offset = mRootIFD->getEntryRecursive(KODAK_KDC_OFFSET); if (!offset || offset->count < 13) ThrowRDE("KDC Decoder: Couldn't find the KDC offset"); const uint32 *offsetarray = offset->getIntArray(); uint32 off = offsetarray[4] + offsetarray[12]; mRaw->dim = iPoint2D(width, height); mRaw->createData(); ByteStream input(mFile->getData(off), mFile->getSize()-off); Decode12BitRawBE(input, width, height); return mRaw; }
RawImage KdcDecoder::decodeRawInternal() { if (!mRootIFD->hasEntryRecursive(COMPRESSION)) ThrowRDE("KDC Decoder: Couldn't find compression setting"); int compression = mRootIFD->getEntryRecursive(COMPRESSION)->getInt(); if (7 != compression) ThrowRDE("KDC Decoder: Unsupported compression %d", compression); uint32 width = 0; uint32 height = 0; TiffEntry *ew = mRootIFD->getEntryRecursive(KODAK_KDC_WIDTH); TiffEntry *eh = mRootIFD->getEntryRecursive(KODAK_KDC_HEIGHT); if (ew && eh) { width = ew->getInt()+80; height = eh->getInt()+70; } else ThrowRDE("KDC Decoder: Unable to retrieve image size"); TiffEntry *offset = mRootIFD->getEntryRecursive(KODAK_KDC_OFFSET); if (!offset || offset->count < 13) ThrowRDE("KDC Decoder: Couldn't find the KDC offset"); const uint32 *offsetarray = offset->getIntArray(); uint32 off = offsetarray[4] + offsetarray[12]; // Offset hardcoding gotten from dcraw if (hints.find("easyshare_offset_hack") != hints.end()) off = off < 0x15000 ? 0x15000 : 0x17000; if (off > mFile->getSize()) ThrowRDE("KDC Decoder: offset is out of bounds"); mRaw->dim = iPoint2D(width, height); mRaw->createData(); ByteStream input(mFile, off); Decode12BitRawBE(input, width, height); return mRaw; }