void OpCreateFontThumbnails::CreateThumbnailFiles(SGDisplayPreviewFonts* pFontItem, INT32 lFontID, PathName pthIndex) { //We want to create three thumbnails: large, medium and small //So for each of the three display modes in the gallery... for (INT32 iDMode=0; iDMode<3; iDMode++) { //Set the display mode into the gallery SGDisplayPreviewFonts::DMode=iDMode; //Now create the thumbnail as a kernel bitmap KernelBitmap* pThisBitmap=NULL; pFontItem->CreateThumbnail(&pThisBitmap); //Now let's get a pointer to the PNG export filter. PNGFilter* pPNGFilter=(PNGFilter*) Filter::FindFilterFromID(FILTERID_PREVIEW_PNG); if (pPNGFilter==NULL) return; //Now create a file for the thumbnail CCDiskFile fileThumb(1024, FALSE, TRUE); //And get a path to save the thumbnail into TCHAR buf[256]; switch (iDMode) { case 0: wsprintf(buf, TEXT("F%05liL.png"), lFontID); break; case 2: wsprintf(buf, TEXT("F%05liS.png"), lFontID); break; case 1: case 3: default: wsprintf(buf, TEXT("F%05liM.png"), lFontID); break; } PathName pthThumb=pthIndex; String_256 strThumbFile=buf; pthThumb.SetFileNameAndType(strThumbFile); //Now export the bitmap to that file pPNGFilter->DoExportBitmap(this, &fileThumb, &pthThumb, pThisBitmap); //And delete the bitmap if (pThisBitmap) delete pThisBitmap; } }
bool DishInfoDialog::saveItem() { QDir root(CBSERVERMONITOR_DISHES_DIR); if (!root.exists()) { if (!root.mkdir(root.absolutePath())) return false; } CBId id(ui->lineEditId->text().trimmed()); if (!_menuItem) { _menuItem = new CBMenuItem(); _menuItem->setRecordDir(CBGlobal::combinePath(root.absolutePath(), id.toString())); root.mkdir(_menuItem->getRecordDir()); _menuItem->setRecordFile(id.toString() + ".xml"); } _menuItem->getDish().setId(id); _menuItem->getDish().setName(ui->lineEditName->text().trimmed()); _menuItem->getDish().setPrice(ui->lineEditPrice->text().trimmed().toFloat()); _menuItem->getDish().setScore(ui->lineEditScore->text().trimmed().toFloat()); _menuItem->getDish().setSummary(ui->lineEditSummary->text().trimmed()); _menuItem->getDish().setDetail(ui->textEditDetail->toPlainText().trimmed()); QStringList tagsList = this->getTags(); _menuItem->getDish().setTags(tagsList); QFile fileOldThumb(CBGlobal::combinePath(_menuItem->getRecordDir(), _menuItem->getDish().getThumb())); QFile fileOldPicture(CBGlobal::combinePath(_menuItem->getRecordDir(), _menuItem->getDish().getPicture())); QFile fileThumb(ui->lineEditThumb->text().trimmed()); QFile filePicture(ui->lineEditPicture->text().trimmed()); if (fileOldThumb.fileName() != fileThumb.fileName()) { QFileInfo info(fileThumb); _menuItem->getDish().setThumb(CBGlobal::getFileName(info.fileName())); qDebug()<<CBGlobal::combinePath(_menuItem->getRecordDir(), _menuItem->getDish().getThumb()); if (fileThumb.exists()) { if (!fileThumb.copy(CBGlobal::combinePath(_menuItem->getRecordDir(), _menuItem->getDish().getThumb()))) return false; } //fileOldThumb.remove(); } if (fileOldPicture.fileName() != filePicture.fileName()) { QFileInfo info(filePicture); _menuItem->getDish().setPicture(CBGlobal::getFileName(info.fileName())); if (filePicture.exists()) { if (filePicture.copy(CBGlobal::combinePath(_menuItem->getRecordDir(), _menuItem->getDish().getPicture()))) qDebug()<<"failed copying picture "<<_menuItem->getDish().getPicture();//fileOldPicture.remove(); } } if (!CBGlobal::writeMenuItemXml(_menuItem)) return false; emit this->sig_itemChanged(_menuItem); return true; }