bool Image::load(const QString& ss) { qDebug("Image::load <%s>", qPrintable(ss)); QString path(ss); // if file path is relative, prepend score path QFileInfo fi(path); if (fi.isRelative()) { path.prepend(_score->fileInfo()->absolutePath() + "/"); fi.setFile(path); } _linkIsValid = false; // assume link fname is invalid QFile f(path); if (!f.open(QIODevice::ReadOnly)) { qDebug("Image::load<%s> failed", qPrintable(path)); return false; } QByteArray ba = f.readAll(); f.close(); _linkIsValid = true; _linkPath = fi.canonicalFilePath(); _storeItem = imageStore.add(_linkPath, ba); _storeItem->reference(this); if (path.endsWith(".svg")) setImageType(IMAGE_SVG); else setImageType(IMAGE_RASTER); return true; }
void Image::read(XmlReader& e) { if (score()->mscVersion() <= 123) _sizeIsSpatium = false; while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "autoScale") setProperty(P_ID::AUTOSCALE, Ms::getProperty(P_ID::AUTOSCALE, e)); else if (tag == "size") setProperty(P_ID::SIZE, Ms::getProperty(P_ID::SIZE, e)); else if (tag == "lockAspectRatio") setProperty(P_ID::LOCK_ASPECT_RATIO, Ms::getProperty(P_ID::LOCK_ASPECT_RATIO, e)); else if (tag == "sizeIsSpatium") setProperty(P_ID::SIZE_IS_SPATIUM, Ms::getProperty(P_ID::SIZE_IS_SPATIUM, e)); else if (tag == "path") _storePath = e.readElementText(); else if (tag == "linkPath") _linkPath = e.readElementText(); else if (tag == "subtype") // obsolete e.skipCurrentElement(); else if (!BSymbol::readProperties(e)) e.unknown(); } // once all paths are read, load img or retrieve it from store // loading from file is tried first to update the stored image, if necessary qDebug("linkPath <%s>", qPrintable(_linkPath)); qDebug("storePath <%s>", qPrintable(_storePath)); QString path; bool loaded = false; // if a store path is given, attempt to get the image from the store if (!_storePath.isEmpty()) { _storeItem = imageStore.getImage(_storePath); if (_storeItem) { _storeItem->reference(this); loaded = true; } // if no image in store, attempt to load from path (for backward compatibility) else loaded = load(_storePath); path = _storePath; } // if no succes from store path, attempt loading from link path (for .mscx files) if (!loaded) { _linkIsValid = load(_linkPath); path = _linkPath; } if (path.endsWith(".svg")) setImageType(ImageType::SVG); else setImageType(ImageType::RASTER); }
void Image::read(XmlReader& e) { if (score()->mscVersion() <= 123) _sizeIsSpatium = false; while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "autoScale") setProperty(P_AUTOSCALE, Ms::getProperty(P_AUTOSCALE, e)); else if (tag == "size") setProperty(P_SIZE, Ms::getProperty(P_SIZE, e)); else if (tag == "lockAspectRatio") setProperty(P_LOCK_ASPECT_RATIO, Ms::getProperty(P_LOCK_ASPECT_RATIO, e)); else if (tag == "sizeIsSpatium") setProperty(P_SIZE_IS_SPATIUM, Ms::getProperty(P_SIZE_IS_SPATIUM, e)); else if (tag == "path") _storePath = e.readElementText(); else if (tag == "linkPath") _linkPath = e.readElementText(); else if (tag == "subtype") // obsolete e.skipCurrentElement(); else if (!BSymbol::readProperties(e)) e.unknown(); } // once all paths are read, load img or retrieve it from store // loading from file is tried first to update the stored image, if necessary qDebug("linkPath <%s>", qPrintable(_linkPath)); qDebug("storePath <%s>", qPrintable(_storePath)); QString path; if (_linkPath.isEmpty() || !load(_linkPath)) { // if could not load img from _linkPath, retrieve from store _storeItem = imageStore.getImage(_storePath); if (_storeItem) { _storeItem->reference(this); } // if not in store, try to load from _storePath for backward compatibility else load(_storePath); path = _storePath; } else path = _linkPath; if (path.endsWith(".svg")) setImageType(IMAGE_SVG); else setImageType(IMAGE_RASTER); }
bool Image::loadFromData(const QString& ss, const QByteArray& ba) { qDebug("Image::loadFromData <%s>", qPrintable(ss)); _linkIsValid = false; _linkPath = ""; _storeItem = imageStore.add(ss, ba); _storeItem->reference(this); if (ss.endsWith(".svg")) setImageType(ImageType::SVG); else setImageType(ImageType::RASTER); return true; }
/* Plot the trace of the walk */ void plotWalk() const { Plotter2D Plotter; auto L = makePlot2DLattice(*this, std::string("OERRW-d") + mtools::toString(delta)); L.setImageType(L.TYPEIMAGE); Plotter[L]; Plotter.gridObject(true)->setUnitCells(); Plotter.range().setRange(zoomOut(fBox2(R))); Plotter.plot(); }
/** * @brief ImageDialog::ImageDialog * @param parent */ ImageDialog::ImageDialog(QWidget *parent) : QDialog(parent), ui(new Ui::ImageDialog) { ui->setupUi(this); #ifdef Q_WS_MAC setWindowFlags((windowFlags() & ~Qt::WindowType_Mask) | Qt::Sheet); setStyleSheet(styleSheet() + " #ImageDialog { border: 1px solid rgba(0, 0, 0, 100); border-top: none; }"); #else setWindowFlags((windowFlags() & ~Qt::WindowType_Mask) | Qt::Dialog); #endif QSettings settings; resize(settings.value("ImageDialog/Size").toSize()); connect(ui->table, SIGNAL(cellClicked(int,int)), this, SLOT(imageClicked(int, int))); connect(ui->table, SIGNAL(sigDroppedImage(QUrl)), this, SLOT(onImageDropped(QUrl))); connect(ui->buttonClose, SIGNAL(clicked()), this, SLOT(reject())); connect(ui->buttonChoose, SIGNAL(clicked()), this, SLOT(chooseLocalImage())); connect(ui->previewSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(onPreviewSizeChange(int))); connect(ui->buttonZoomIn, SIGNAL(clicked()), this, SLOT(onZoomIn())); connect(ui->buttonZoomOut, SIGNAL(clicked()), this, SLOT(onZoomOut())); QMovie *movie = new QMovie(":/img/spinner.gif"); movie->start(); ui->labelSpinner->setMovie(movie); clear(); setImageType(TypePoster); m_currentDownloadReply = 0; QPixmap zoomOut(":/img/zoom_out.png"); QPixmap zoomIn(":/img/zoom_in.png"); QPainter p; p.begin(&zoomOut); p.setCompositionMode(QPainter::CompositionMode_SourceIn); p.fillRect(zoomOut.rect(), QColor(0, 0, 0, 150)); p.end(); p.begin(&zoomIn); p.setCompositionMode(QPainter::CompositionMode_SourceIn); p.fillRect(zoomIn.rect(), QColor(0, 0, 0, 150)); p.end(); ui->buttonZoomOut->setIcon(QIcon(zoomOut)); ui->buttonZoomIn->setIcon(QIcon(zoomIn)); m_noElementsLabel = new QLabel(tr("No images found"), ui->table); m_noElementsLabel->setMargin(10); m_noElementsLabel->hide(); }
void Image::read(XmlReader& e) { if (score()->mscVersion() <= 114) _sizeIsSpatium = false; while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "autoScale") readProperty(e, Pid::AUTOSCALE); else if (tag == "size") readProperty(e, Pid::SIZE); else if (tag == "lockAspectRatio") readProperty(e, Pid::LOCK_ASPECT_RATIO); else if (tag == "sizeIsSpatium") // setting this using the property Pid::SIZE_IS_SPATIUM breaks, because the // property setter attempts to maintain a constant size. If we're reading, we // don't want to do that, because the stored size will be in: // mm if size isn't spatium // sp if size is spatium _sizeIsSpatium = e.readBool(); else if (tag == "path") _storePath = e.readElementText(); else if (tag == "linkPath") _linkPath = e.readElementText(); else if (tag == "subtype") // obsolete e.skipCurrentElement(); else if (!BSymbol::readProperties(e)) e.unknown(); } // once all paths are read, load img or retrieve it from store // loading from file is tried first to update the stored image, if necessary qDebug("linkPath <%s>", qPrintable(_linkPath)); qDebug("storePath <%s>", qPrintable(_storePath)); QString path; bool loaded = false; // if a store path is given, attempt to get the image from the store if (!_storePath.isEmpty()) { _storeItem = imageStore.getImage(_storePath); if (_storeItem) { _storeItem->reference(this); loaded = true; } // if no image in store, attempt to load from path (for backward compatibility) else loaded = load(_storePath); path = _storePath; } // if no success from store path, attempt loading from link path (for .mscx files) if (!loaded) { _linkIsValid = load(_linkPath); path = _linkPath; } if (path.endsWith(".svg")) setImageType(ImageType::SVG); else setImageType(ImageType::RASTER); }
void ofPixels_<PixelType>::setNumChannels(int numChannels){ if(!isAllocated() || numChannels==getNumChannels()) return; setImageType(getImageTypeFromChannels(numChannels)); }
void Image::init() { setImageType(CIFAR10); // todo: FUTUREWORK -- allow for different imagesets mClassification = -1; }
void FhoIconCreator::setImageType(QString fileExtension) { setImageType("", fileExtension); }
FhoIconCreator::FhoIconCreator() { forceDefaultImage = false; setImageType("png"); }