void ChangeDirThread::fixFilePath(UTIL::FS::Path &file) { UTIL::FS::Path fdest(m_szDest, "", false); UTIL::FS::Path path(m_szCurDir, "", false); for (size_t y=path.getFolderCount(); y<file.getFolderCount(); y++) fdest += file.getFolder(y); fdest += file.getFile(); file = fdest; }
void CTransformationThread::Process(size_t index) { ASSERT(index < files_.size()); ASSERT(files_[index] != 0); ASSERT(index < files_.size()); PhotoInfo& photo= *files_[index]; // output file Path output= GetDestFileName(index); if (transformation_.size() == 1 && transformation_.front().needs_input_file_) { transformation_.front().fn_transform_img_(photo.GetOriginalPath(), output); return; // exclusive transformation done, exit } // start loading SetOperationLabel(IDS_IMG_TRANSFORM_LOADING); CImageDecoderPtr decoder= photo.GetDecoder(); decoder->SetProgressCallback(boost::bind(&CTransformationThread::LinesDecoded, this, _1, _2, _3)); CSize img_size(0, 0); Dib dib; if (ImageStat status= decoder->DecodeImg(dib, img_size, false)) throw ImageStatMsg(status); SetOperationLabel(IDS_IMG_TRANSFORM_APPLYING); for (size_t i= 0; i < transformation_.size(); ++i) { ASSERT(!transformation_[i].needs_input_file_); transformation_[i].fn_transform_bmp_(dib); } // EXIF block std::vector<uint8> exif; if (params_.copy_exif_ && photo.IsExifDataPresent()) { ExifBlock exifBlock; if (photo.ReadExifBlock(exifBlock)) { exifBlock.ModifySizeFields(dib.GetSize(), true); exifBlock.GetExifMarkerBlock(exif); } } // start storing result SetOperationLabel(IDS_IMG_TRANSFORM_STORING); // destination file CFileDataDestination fdest(output.c_str()); // write transformed photo if (!encoder_->Encode(fdest, &dib, &exif)) throw _T("Error encoding JPEG file."); }