void TextZone::setDoc(MainTextDocument *doc) { textDocument = doc; this->setDocument(doc); if(this->objectName().mid(0,7) == "textDoc" || this->objectName().mid(0,6) == "synDoc" || this->objectName().mid(0,7) == "noteDoc") this->setIdNumber(this->objectName().mid(this->objectName().indexOf("_") + 1).toInt()); connect(this, SIGNAL(cursorPositionChanged(int)), doc, SLOT(setCursorPos(int))); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChangedSlot())); // activate spell check at start QSettings settings; this->activateSpellcheck(settings.value("SpellChecking/globalSpellCheckActivated", true).toBool()); //minimap : createThumbnail(); connect(doc, SIGNAL(contentsChanged()), this, SLOT(createThumbnail())); }
void SaveLoadManager::writeSavegameHeader(Common::OutSaveFile *out, hopkinsSavegameHeader &header) { // Write out a savegame header out->write(SAVEGAME_STR, SAVEGAME_STR_SIZE + 1); out->writeByte(HOPKINS_SAVEGAME_VERSION); // Write savegame name out->write(header._saveName.c_str(), header._saveName.size() + 1); // Create a thumbnail and save it Graphics::Surface *thumb = new Graphics::Surface(); createThumbnail(thumb); Graphics::saveThumbnail(*out, *thumb); thumb->free(); delete thumb; // Write out the save date/time TimeDate td; g_system->getTimeAndDate(td); out->writeSint16LE(td.tm_year + 1900); out->writeSint16LE(td.tm_mon + 1); out->writeSint16LE(td.tm_mday); out->writeSint16LE(td.tm_hour); out->writeSint16LE(td.tm_min); out->writeUint32LE(_vm->_events->_gameCounter); }
void Game::writeSavegameHeader(Common::OutSaveFile *out, MADSSavegameHeader &header) { // Write out a savegame header out->write(SAVEGAME_STR, SAVEGAME_STR_SIZE + 1); out->writeByte(MADS_SAVEGAME_VERSION); // Write savegame name out->write(header._saveName.c_str(), header._saveName.size()); out->writeByte('\0'); // Handle the thumbnail. If there's already one set by the game, create one if (!_saveThumb) createThumbnail(); Graphics::saveThumbnail(*out, *_saveThumb); _saveThumb->free(); delete _saveThumb; _saveThumb = nullptr; // Write out the save date/time TimeDate td; g_system->getTimeAndDate(td); out->writeSint16LE(td.tm_year + 1900); out->writeSint16LE(td.tm_mon + 1); out->writeSint16LE(td.tm_mday); out->writeSint16LE(td.tm_hour); out->writeSint16LE(td.tm_min); out->writeUint32LE(_vm->_events->getFrameCounter()); }
void Menu::goToNode(uint16 node) { if (_vm->_state->getMenuSavedAge() == 0 && _vm->_state->getLocationRoom() != 901) { // Entering menu, save current location ... _vm->_state->setMenuSavedAge(_vm->_state->getLocationAge()); _vm->_state->setMenuSavedRoom(_vm->_state->getLocationRoom()); _vm->_state->setMenuSavedNode(_vm->_state->getLocationNode()); // ... and capture the screen Graphics::Surface *big = _vm->_gfx->getScreenshot(); Graphics::Surface *thumb = createThumbnail(big); _vm->_state->setSaveThumbnail(thumb); big->free(); delete big; // Reset some sound variables if (_vm->_state->getLocationAge() == 6 && _vm->_state->getSoundEdannaUnk587() == 1 && _vm->_state->getSoundEdannaUnk1031()) { _vm->_state->setSoundEdannaUnk587(0); } if (_vm->_state->getLocationAge() == 10 && _vm->_state->getSoundAmateriaUnk627() == 1 && _vm->_state->getSoundAmateriaUnk930()){ _vm->_state->setSoundAmateriaUnk627(0); } if (_vm->_state->getLocationAge() == 7 && _vm->_state->getSoundVoltaicUnk540() == 1 && _vm->_state->getSoundVoltaicUnk1146()) { _vm->_state->setSoundVoltaicUnk540(0); } _vm->_sound->stopMusic(60); _vm->_state->setSoundScriptsSuspended(1); } _vm->_state->setMenuEscapePressed(0); _vm->_state->setLocationNextAge(9); _vm->_state->setLocationNextRoom(901); _vm->goToNode(node, kTransitionNone); }
void CProjectItem::writeSavegameHeader(SimpleFile *file, TitanicSavegameHeader &header) { // Write out a savegame header file->write(SAVEGAME_STR, SAVEGAME_STR_SIZE + 1); file->writeByte(CURRENT_SAVEGAME_VERSION); // Write savegame name file->write(header._saveName.c_str(), header._saveName.size()); file->writeByte('\0'); // Create a thumbnail of the screen and save it out Graphics::Surface *thumb = createThumbnail(); Graphics::saveThumbnail(*file, *thumb); thumb->free(); delete thumb; // Write out the save date/time TimeDate td; g_system->getTimeAndDate(td); file->writeUint16LE(td.tm_year + 1900); file->writeUint16LE(td.tm_mon + 1); file->writeUint16LE(td.tm_mday); file->writeUint16LE(td.tm_hour); file->writeUint16LE(td.tm_min); file->writeUint32LE(g_vm->_events->getFrameCounter()); }
bool createThumbnailFromScreen(Graphics::Surface *surf) { assert(surf); Graphics::Surface screen; if (!grabScreen565(&screen)) return false; return createThumbnail(*surf, screen); }
void uVision::on_openFiles_clicked() { waitseconds = 1;//reset QStringList list = QFileDialog::getOpenFileNames(this, "Open one or more pictures", "", "*.jpg *.png *.bmp"); if( list.count() == 0) { return; } //open files one by one, and create thread to create thumbnail for each file QStringList::Iterator it = list.begin(); while(it != list.end()) { createThumbnail(*it); ++it; } }
bool createThumbnail(Graphics::Surface *surf, const uint8 *pixels, int w, int h, const uint8 *palette) { assert(surf); Graphics::Surface screen; screen.create(w, h, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); for (uint y = 0; y < screen.h; ++y) { for (uint x = 0; x < screen.w; ++x) { byte r, g, b; r = palette[pixels[y * w + x] * 3]; g = palette[pixels[y * w + x] * 3 + 1]; b = palette[pixels[y * w + x] * 3 + 2]; *((uint16 *)screen.getBasePtr(x, y)) = Graphics::RGBToColor<Graphics::ColorMasks<565> >(r, g, b); } } return createThumbnail(*surf, screen); }
void Menu::goToNode(uint16 node) { if (_vm->_state->getMenuSavedAge() == 0 && _vm->_state->getLocationRoom() != 901) { // Entering menu, save current location ... _vm->_state->setMenuSavedAge(_vm->_state->getLocationAge()); _vm->_state->setMenuSavedRoom(_vm->_state->getLocationRoom()); _vm->_state->setMenuSavedNode(_vm->_state->getLocationNode()); // ... and capture the screen Graphics::Surface *big = _vm->_gfx->getScreenshot(); createThumbnail(big, _saveThumb); big->free(); delete big; } _vm->_state->setMenuEscapePressed(0); _vm->_state->setLocationNextAge(9); _vm->_state->setLocationNextRoom(901); _vm->goToNode(node, 2); }
bool createThumbnail(Graphics::Surface *surf, const uint8 *pixels, int w, int h, const uint8 *palette) { assert(surf); Graphics::Surface screen; screen.create(w, h, 2); for (uint y = 0; y < screen.h; ++y) { for (uint x = 0; x < screen.w; ++x) { byte r, g, b; r = palette[pixels[y * w + x] * 3]; g = palette[pixels[y * w + x] * 3 + 1]; b = palette[pixels[y * w + x] * 3 + 2]; ((uint16 *)screen.pixels)[y * screen.w + x] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(r, g, b); } } return createThumbnail(*surf, screen); }
PageScreen::PageScreen(WebView* view, QWidget* parent) : QDialog(parent) , ui(new Ui::PageScreen) , m_view(view) , m_imageScaling(0) , m_horizontalScrollbarSize(0) , m_verticalScrollbarSize(0) { setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(this); QMovie* mov = new QMovie(":html/loading.gif"); ui->label->setMovie(mov); mov->start(); m_pageTitle = m_view->title(); connect(ui->buttonBox->button(QDialogButtonBox::Save), SIGNAL(clicked()), this, SLOT(dialogAccepted())); connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(close())); QTimer::singleShot(200, this, SLOT(createThumbnail())); }
PageScreen::PageScreen(WebView* view, QWidget* parent) : QDialog(parent) , ui(new Ui::PageScreen) , m_view(view) , m_imageScaling(0) { setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(this); m_formats[0] = QLatin1String("PNG"); m_formats[1] = QLatin1String("BMP"); m_formats[2] = QLatin1String("JPG"); m_formats[3] = QLatin1String("PPM"); m_formats[4] = QLatin1String("TIFF"); m_formats[5] = QLatin1String("PDF"); QHashIterator<int, QString> i(m_formats); while (i.hasNext()) { i.next(); ui->formats->addItem(tr("Save as %1").arg(i.value())); } // Set png as a default format m_pageTitle = m_view->title(); ui->location->setText(QString("%1/%2.png").arg(QDir::homePath(), QzTools::filterCharsFromFilename(m_pageTitle))); QMovie* mov = new QMovie(":html/loading.gif"); ui->label->setMovie(mov); mov->start(); connect(ui->changeLocation, SIGNAL(clicked()), this, SLOT(changeLocation())); connect(ui->formats, SIGNAL(currentIndexChanged(int)), this, SLOT(formatChanged())); connect(ui->buttonBox->button(QDialogButtonBox::Save), SIGNAL(clicked()), this, SLOT(dialogAccepted())); connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(close())); QTimer::singleShot(200, this, SLOT(createThumbnail())); }
bool Score::saveCompressedFile(QIODevice* f, QFileInfo& info, bool onlySelection, bool doCreateThumbnail) { MQZipWriter uz(f); QString fn = info.completeBaseName() + ".mscx"; QBuffer cbuf; cbuf.open(QIODevice::ReadWrite); XmlWriter xml(this, &cbuf); xml << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; xml.stag("container"); xml.stag("rootfiles"); xml.stag(QString("rootfile full-path=\"%1\"").arg(XmlWriter::xmlString(fn))); xml.etag(); for (ImageStoreItem* ip : imageStore) { if (!ip->isUsed(this)) continue; QString path = QString("Pictures/") + ip->hashName(); xml.tag("file", path); } xml.etag(); xml.etag(); cbuf.seek(0); //uz.addDirectory("META-INF"); uz.addFile("META-INF/container.xml", cbuf.data()); // save images //uz.addDirectory("Pictures"); foreach (ImageStoreItem* ip, imageStore) { if (!ip->isUsed(this)) continue; QString path = QString("Pictures/") + ip->hashName(); uz.addFile(path, ip->buffer()); } // create thumbnail if (doCreateThumbnail && !pages().isEmpty()) { QImage pm = createThumbnail(); QByteArray ba; QBuffer b(&ba); if (!b.open(QIODevice::WriteOnly)) qDebug("open buffer failed"); if (!pm.save(&b, "PNG")) qDebug("save failed"); uz.addFile("Thumbnails/thumbnail.png", ba); } #ifdef OMR // // save OMR page images // if (masterScore()->omr()) { int n = masterScore()->omr()->numPages(); for (int i = 0; i < n; ++i) { QString path = QString("OmrPages/page%1.png").arg(i+1); QBuffer cbuf1; OmrPage* page = masterScore()->omr()->page(i); const QImage& image = page->image(); if (!image.save(&cbuf1, "PNG")) { MScore::lastError = tr("save file: cannot save image (%1x%2)").arg(image.width(), image.height()); return false; } uz.addFile(path, cbuf1.data()); cbuf1.close(); } } #endif // // save audio // if (_audio) uz.addFile("audio.ogg", _audio->data()); QBuffer dbuf; dbuf.open(QIODevice::ReadWrite); saveFile(&dbuf, true, onlySelection); dbuf.seek(0); uz.addFile(fn, dbuf.data()); uz.close(); return true; }
void SimpleViewer::processQUrlList(QList<QUrl>& images, QDomDocument& xmlDoc, QDomElement& galleryElem, QDomElement& photosElem) { QImage image; QImage thumbnail; QString tmp; QString newName; int index = 1; int maxSize = d->settings->imagesExportSize; bool resizeImages = d->settings->resizeExportImages; bool fixOrientation = d->settings->fixOrientation; QUrl thumbsDir = QUrl::fromLocalFile(d->tempDir->path()); thumbsDir.setPath(thumbsDir.path() + QLatin1String("/thumbs/")); QUrl imagesDir = QUrl::fromLocalFile(d->tempDir->path()); imagesDir.setPath(imagesDir.path() + QLatin1String("/images/")); qSort(images.begin(), images.end(), cmpUrl); for (QList<QUrl>::ConstIterator it = images.constBegin(); !d->canceled && (it != images.constEnd()) ; ++it) { QApplication::processEvents(); QUrl url = *it; QFileInfo fi(url.toLocalFile()); //video can't be exported, need to add for all video files if (fi.suffix().toUpper() == QLatin1String("MOV")) continue; d->progressWdg->addedAction(i18n("Processing %1", url.fileName()), StartingMessage); // Clear image. image = QImage(); if (d->interface) { image = d->interface->preview(url); } if (image.isNull()) { image.load(url.toLocalFile()); } if (image.isNull()) { d->progressWdg->addedAction(i18n("Could not open image '%1'", url.fileName()), WarningMessage); continue; } if (d->settings->plugType == 0) { // Thumbnails are generated only for simpleviewer plugin if (!createThumbnail(image, thumbnail)) { d->progressWdg->addedAction(i18n("Could not create thumbnail from '%1'", url.fileName()), WarningMessage); continue; } } if (resizeImages && !resizeImage(image, maxSize, image)) { d->progressWdg->addedAction(i18n("Could not resize image '%1'", url.fileName()), WarningMessage); continue; } if (d->meta && d->meta->load(url)) { bool rotated = false; newName = QString::fromUtf8("%1.%2").arg(tmp.sprintf("%03i", index)).arg(QLatin1String("jpg")); if (d->settings->plugType == 0) { QUrl thumbnailPath(thumbsDir); thumbnailPath.setPath(thumbnailPath.path() + newName); if (resizeImages && fixOrientation) d->meta->rotateExifQImage(thumbnail, d->meta->getImageOrientation()); thumbnail.save(thumbnailPath.toLocalFile(), "JPEG"); } QUrl imagePath(imagesDir); imagePath.setPath(imagePath.path() + newName); if (resizeImages && fixOrientation) rotated = d->meta->rotateExifQImage(image, d->meta->getImageOrientation()); image.save(imagePath.toLocalFile(), "JPEG"); // Backup metadata from original image. d->meta->setImageProgramId(QLatin1String("Kipi-plugins"), kipipluginsVersion()); d->meta->setImageDimensions(image.size()); if (rotated) d->meta->setImageOrientation(MetadataProcessor::NORMAL); d->meta->save(imagePath); } d->width = image.width(); d->height = image.height(); if (d->settings->plugType!=2) cfgAddImage(xmlDoc, galleryElem, url, newName); else cfgAddImage(xmlDoc, photosElem, url, newName); d->progressWdg->setProgress(++d->action, d->totalActions); index++; } }
OrionMenuView::OrionMenuView(M4Engine *Vm, int x, int y, MenuType menuType, bool calledFromMainMenu, bool loadSaveFromHotkey): DialogView(Vm, x, y, true) { _menuType = menuType; _screenType = VIEWID_MENU; _screenFlags.layer = LAYER_MENU; _screenFlags.get = SCREVENT_ALL; _screenFlags.blocks = SCREVENT_ALL; _screenFlags.immovable = true; //_screenFlags.immovable = false; // uncomment to make menu movable _coords.left = x; _coords.top = y; _currentItem = NULL; _escapeHandler = &OrionCallbacks::closeMenuFn; _returnHandler = NULL; _saveNames = NULL; _savegameThumbnail = NULL; _deleteSaveDesc = false; _closeFlag = false; _calledFromMainMenu = calledFromMainMenu; _loadSaveFromHotkey = loadSaveFromHotkey; _interfaceWasVisible = _vm->_interfaceView->isVisible(); if (_interfaceWasVisible) _vm->_interfaceView->hide(); _vm->_mouse->setCursorNum(CURSOR_ARROW); switch (menuType) { case GAME_MENU: loadSprites(MENU_GAME); // Add menu contents _menuObjects.push_back(new MenuButton(this, BTNID_MAIN, 45, 53, 24, 24, &OrionCallbacks::closeMenuFn)); _menuObjects.push_back(new MenuButton(this, BTNID_OPTIONS, 45, 94, 24, 24, &OrionCallbacks::gameOptionsMenuFn)); _menuObjects.push_back(new MenuButton(this, BTNID_RESUME, 45, 135, 24, 24, &OrionCallbacks::closeMenuFn)); _menuObjects.push_back(new MenuButton(this, BTNID_QUIT, 141, 135, 24, 24, &OrionCallbacks::gameExitFn)); _menuObjects.push_back(new MenuButton(this, BTNID_SAVE, 141, 53, 24, 24, &OrionCallbacks::gameSaveGameFn, _calledFromMainMenu)); _menuObjects.push_back(new MenuButton(this, BTNID_LOAD, 141, 94, 24, 24, &OrionCallbacks::gameLoadGameFn, !_vm->_saveLoad->hasSaves())); _escapeHandler = &OrionCallbacks::closeMenuFn; _returnHandler = &OrionCallbacks::closeMenuFn; break; case OPTIONS_MENU: loadSprites(MENU_OPTIONS); // Store the original settings in case user aborts dialog _originalMidiVolume = _vm->midi()->getVolume(); // Add menu contents // TODO: Currently the Digi slider isn't hooked up to anything _menuObjects.push_back(new MenuButton(this, OPTIONID_CANCEL, 93, 141, 74, 43, &OrionCallbacks::optionsCancelFn, false, false, OBJTYPE_OM_CANCEL)); _menuObjects.push_back(new MenuButton(this, OPTIONID_DONE, 168, 141, 74, 43, &OrionCallbacks::optionsDoneFn, false, false, OBJTYPE_OM_DONE)); _menuObjects.push_back(new MenuHorizSlider(this, OPTIONID_HSLIDER_MIDI, 47, 64, 212, 24, _originalMidiVolume * 100 / 255, &OrionCallbacks::optionsMidiSliderFn, true)); _menuObjects.push_back(new MenuHorizSlider(this, OPTIONID_HSLIDER_DIGI, 47, 104, 212, 24, 0, &OrionCallbacks::optionsDigiSliderFn, true)); _escapeHandler = &OrionCallbacks::optionsEscapeFn; _returnHandler = &OrionCallbacks::optionsReturnFn; break; case SAVE_MENU: case LOAD_MENU: loadSprites(MENU_SAVELOAD); // Set up the defaults for the window _topSaveSlotIndex = 0; _selectedSlot = -1; _highlightedSlot = -1; _saveNames = _vm->_saveLoad->getSaves(); // Set up menu elements _menuObjects.push_back(new MenuMessage(this, SLTAG_SAVELOAD_LABEL, 50, 241, 70, 16)); _menuObjects.push_back(new MenuButton(this, SLTAG_SAVELOAD, 214, 384, 72, 41, (menuType == SAVE_MENU) ? &OrionCallbacks::saveLoadSaveFn : &OrionCallbacks::saveLoadLoadFn, true, true, (menuType == SAVE_MENU) ? OBJTYPE_SL_SAVE : OBJTYPE_SL_LOAD)); _menuObjects.push_back(new MenuButton(this, SLTAG_CANCEL, 139, 384, 74, 43, &OrionCallbacks::saveLoadCancelFn, false, false, OBJTYPE_SL_CANCEL)); _menuObjects.push_back(new MenuVertSlider(this, SLTAG_VSLIDER, 291, 255, 23, 127, 0, &OrionCallbacks::saveLoadSliderFn)); if (_menuType == SAVE_MENU) _savegameThumbnail = createThumbnail(); _menuObjects.push_back(new MenuImage(this, SLTAG_THUMBNAIL, 66, 28, 215, 162, (_savegameThumbnail == NULL) ? _sprites->getFrame(SL_EMPTY_THUMBNAIL) : _savegameThumbnail)); { SaveGameIterator slot = _saveNames->begin(); for (uint slotIndex = 0; slotIndex < SL_NUM_VISIBLE_SLOTS; ++slotIndex, ++slot) { // Get save slot bool isEmpty = (slotIndex >= _saveNames->size()) || (*slot).empty(); _menuObjects.push_back(new MenuSaveLoadText(this, SLTAG_SLOTS_START + slotIndex, 50, 256 + slotIndex * 15, 238, 15, &OrionCallbacks::saveLoadSlotFn, (menuType == LOAD_MENU) && isEmpty, true, (menuType == LOAD_MENU), isEmpty ? EmptySaveString : slot->c_str(), slotIndex + 1)); } } _escapeHandler = &OrionCallbacks::saveLoadEscapeFn; _returnHandler = &OrionCallbacks::saveLoadReturnFn; break; default: error("Unknown menu type"); break; } // Draw all the items onto the background surface for (MenuObjectsIterator i = _menuObjects.begin(); i != _menuObjects.end(); ++i) (*i)->onRefresh(); }
static bool createThumbnail(Graphics::Surface &out, Graphics::Surface &in) { uint16 width = in.w; uint16 inHeight = in.h; if (width < 320) { // Special case to handle MM NES (uses a screen width of 256) width = 320; // center MM NES screen Graphics::Surface newscreen; newscreen.create(width, in.h, in.bytesPerPixel); uint8 *dst = (uint8 *)newscreen.getBasePtr((320 - in.w) / 2, 0); const uint8 *src = (const uint8 *)in.getBasePtr(0, 0); uint16 height = in.h; while (height--) { memcpy(dst, src, in.pitch); dst += newscreen.pitch; src += in.pitch; } in.free(); in = newscreen; } else if (width == 720) { // Special case to handle Hercules mode // // NOTE: This code is pretty SCUMM specific. // For other games this code might cut off // not only the menu, but also other graphics. width = 640; inHeight = 400; // cut off menu and so on.. Graphics::Surface newscreen; newscreen.create(width, 400, in.bytesPerPixel); uint8 *dst = (uint8 *)newscreen.getBasePtr(0, (400 - 240) / 2); const uint8 *src = (const uint8 *)in.getBasePtr(41, 28); for (int y = 0; y < 240; ++y) { memcpy(dst, src, 640 * in.bytesPerPixel); dst += newscreen.pitch; src += in.pitch; } in.free(); in = newscreen; } else if (width == 640 && inHeight == 440) { // Special case to handle KQ6 Windows: resize the screen to 640x480, // adding a black band in the bottom. inHeight = 480; Graphics::Surface newscreen; newscreen.create(width, 480, in.bytesPerPixel); memcpy(newscreen.getBasePtr(0, 0), in.getBasePtr(0, 0), width * 440 * in.bytesPerPixel); in.free(); in = newscreen; } uint16 newHeight = !(inHeight % 240) ? kThumbnailHeight2 : kThumbnailHeight1; out.create(kThumbnailWidth, newHeight, sizeof(uint16)); createThumbnail((const uint8 *)in.pixels, width * sizeof(uint16), (uint8 *)out.pixels, out.pitch, width, inHeight); in.free(); return true; }