bool readDng() { try { // Due to the limit of DNG SDK, we need to reset host and info. fHost.reset(new SkDngHost(&fAllocator)); fInfo.reset(new dng_info); fDngStream.reset(new SkDngStream(fStream)); fHost->ValidateSizes(); fInfo->Parse(*fHost, *fDngStream); fInfo->PostParse(*fHost); if (!fInfo->IsValidDNG()) { return false; } fNegative.reset(fHost->Make_dng_negative()); fNegative->Parse(*fHost, *fDngStream, *fInfo); fNegative->PostParse(*fHost, *fDngStream, *fInfo); fNegative->SynchronizeMetadata(); dng_point cfaPatternSize(0, 0); if (fNegative->GetMosaicInfo() != nullptr) { cfaPatternSize = fNegative->GetMosaicInfo()->fCFAPatternSize; } this->init(static_cast<int>(fNegative->DefaultCropSizeH().As_real64()), static_cast<int>(fNegative->DefaultCropSizeV().As_real64()), cfaPatternSize); return true; } catch (...) { return false; } }
bool initFromPiex() { // Does not take the ownership of rawStream. SkPiexStream piexStream(fStream.get()); ::piex::PreviewImageData imageData; if (::piex::IsRaw(&piexStream) && ::piex::GetPreviewImageData(&piexStream, &imageData) == ::piex::Error::kOk) { dng_point cfaPatternSize(imageData.cfa_pattern_dim[1], imageData.cfa_pattern_dim[0]); return this->init(static_cast<int>(imageData.full_width), static_cast<int>(imageData.full_height), cfaPatternSize); } return false; }
bool initFromPiex() { // Does not take the ownership of rawStream. SkPiexStream piexStream(fStream.get()); ::piex::PreviewImageData imageData; if (::piex::IsRaw(&piexStream) && ::piex::GetPreviewImageData(&piexStream, &imageData) == ::piex::Error::kOk) { // Verify the size information, as it is only optional information for PIEX. if (imageData.full_width == 0 || imageData.full_height == 0) { return false; } dng_point cfaPatternSize(imageData.cfa_pattern_dim[1], imageData.cfa_pattern_dim[0]); this->init(static_cast<int>(imageData.full_width), static_cast<int>(imageData.full_height), cfaPatternSize); return true; } return false; }