Example #1
0
/*!
   Constructs a QRawFont representing the font contained in the supplied
   \a fontData for the size (in pixels) given by \a pixelSize, and using the
   hinting preference specified by \a hintingPreference.

   \note The data must contain a TrueType or OpenType font.
*/
QRawFont::QRawFont(const QByteArray &fontData,
                   qreal pixelSize,
                   QFont::HintingPreference hintingPreference)
    : d(new QRawFontPrivate)
{
    loadFromData(fontData, pixelSize, hintingPreference);
}
Example #2
0
/*!
   Replaces the current QRawFont with the contents of the file referenced
   by \a fileName for the size (in pixels) given by \a pixelSize, and using the
   hinting preference specified by \a hintingPreference.

   The file must reference a TrueType or OpenType font.

   \sa loadFromData()
*/
void QRawFont::loadFromFile(const QString &fileName,
                            qreal pixelSize,
                            QFont::HintingPreference hintingPreference)
{
    QFile file(fileName);
    if (file.open(QIODevice::ReadOnly))
        loadFromData(file.readAll(), pixelSize, hintingPreference);
}
Example #3
0
bool JpegContent::load(const QString& path)
{
    QFile file(path);
    if (!file.open(QIODevice::ReadOnly)) {
        qCritical() << "Could not open '" << path << "' for reading\n";
        return false;
    }
    return loadFromData(file.readAll());
}
static QSharedPointer<QPixmap> readPic(QString path)
{
    auto p = QSharedPointer<QPixmap>::create(path, "1");
    if(!p || p->width() == 0)
    {
        QByteArray arr = expansions->open(path);
        p->loadFromData(arr, "1");
    }
    return p;
}
Example #5
0
bool JpegContent::loadFromData(const QByteArray& data)
{
    Exiv2::Image::AutoPtr image;
    Exiv2ImageLoader loader;
    if (!loader.load(data)) {
        qCritical() << "Could not load image with Exiv2, reported error:" << loader.errorMessage();
    }
    image = loader.popImage();

    return loadFromData(data, image.get());
}
Example #6
0
PHRect PHGLTexture2D::loadFromFile(const string & fname, bool antialiasing)
{
    size_t size, width, height, bufW, bufH;
    enum pixelFormat format;
    uint8_t * b = dataFromFile(fname, width, height, bufW, bufH, !supportsNPOT(gm), size, format);
    
    PHRect r = loadFromData(b, width, height, bufW, bufH, format, antialiasing);
    
    delete[] b;
    return r;
}
Example #7
0
		QPixmap ResourceLoader::LoadPixmap (const QString& basename) const
		{
			if (CachePixmaps_.contains (basename))
				return *CachePixmaps_ [basename];

			auto dev = LoadIcon (basename, true);
			if (!dev)
				return QPixmap ();

			const auto& data = dev->readAll ();
			auto px = new QPixmap;
			px->loadFromData (data);
			CachePixmaps_.insert (basename, px, data.size ());
			return *px;
		}
bool QPixmap::loadFromData( const uchar *buf, uint len, const char *format,
			    ColorMode mode )
{
    int conversion_flags = 0;
    switch (mode) {
      case Color:
	conversion_flags |= ColorOnly;
	break;
      case Mono:
	conversion_flags |= MonoOnly;
	break;
      default:
	break;// Nothing.
    }
    return loadFromData( buf, len, format, conversion_flags );
}
Example #9
0
//------------------------------------------------------------------
void ofxAdvancedImage::loadFromUrl(string _url) {
	//Get the data
	string str=loader.loadFromUrl(_url);
	
	int bytesToRead = str.size();
	
	unsigned char buff[bytesToRead];
	memset(buff, 0, bytesToRead);
	
	for(int i = 0; i < bytesToRead; i++){
		buff[i] = str[i];
	}
	
	//Load the Image from the Stream
	loadFromData(buff, bytesToRead);
}
Example #10
0
Bitmap *loadFromPath(std::string const &path)
{
    bitmap_init();
    Bitmap *ret = NULL;
    IxRead *ir = IxRead::readFromFile(path.c_str());
    try
    {
        ret = loadFromData(ir->dataSegment(0, ir->size()), ir->size(), fileext(path));
    }
    catch (...)
    {
        delete ir;
        throw;
    }
    delete ir;
    return ret;
}
Example #11
0
bool JpegContent::save(QIODevice* device)
{
    if (!d->mImage.isNull()) {
        if (!d->updateRawDataFromImage()) {
            return false;
        }
    }

    if (d->mRawData.size() == 0) {
        d->mErrorString = i18nc("@info", "No data to store.");
        return false;
    }

    if (d->mPendingTransformation) {
        applyPendingTransformation();
        d->mPendingTransformation = false;
    }

    Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open((unsigned char*)d->mRawData.data(), d->mRawData.size());

    // Store Exif info
    image->setExifData(d->mExifData);
    image->setComment(d->mComment.toUtf8().data());
    image->writeMetadata();

    // Update mRawData
    Exiv2::BasicIo& io = image->io();
    d->mRawData.resize(io.size());
    io.read((unsigned char*)d->mRawData.data(), io.size());

    QDataStream stream(device);
    stream.writeRawData(d->mRawData.data(), d->mRawData.size());

    // Make sure we are up to date
    loadFromData(d->mRawData);
    return true;
}
Example #12
0
QPixmap::QPixmap( const QByteArray & img_data )
    : QPaintDevice( QInternal::Pixmap )
{
    init( 0, 0, 0, FALSE, defOptim );
    loadFromData( img_data );
}
Example #13
0
bool QPixmap::loadFromData( const QByteArray &buf, const char *format,
			    int conversion_flags )
{
    return loadFromData( (const uchar *)(buf.data()), buf.size(),
			 format, conversion_flags );
}
Example #14
0
Bitmap *Bitmap::readFromFile(IxRead *file, GLContext *ctx, std::string const &dir, std::string const &filename)
{
    return loadFromData(file->dataSegment(0, file->size()), file->size(), fileext(filename));
}
Example #15
0
void dos_qpixmap_loadFromData(DosPixmap *vptr, const unsigned char* data, unsigned int len)
{
    auto pixmap = static_cast<QPixmap *>(vptr);
    pixmap->loadFromData(data, len);
}
Example #16
0
void NoteBook::sync() {
    qDebug() << "NoteBook::sync()";

    bool ok;
    QByteArray result = EdamProtocol::GetInstance()->getNetworkManager()->postData(EdamProtocol::GetInstance()->getNoteStoreUri(), createPushContentPost(), ok);

    if (!ok)
        return;

    TBinaryProtocol *bin = new TBinaryProtocol(result);

    QString name;
    TMessageType messageType;
    qint32 seqid;
    bin->readMessageBegin(name, messageType, seqid);
    if (messageType == T_EXCEPTION){
        qDebug() << "Error:" << "checkVersion failed: unknown result";
        return;
    }
    qDebug() << name << messageType << seqid;

    hash data = bin->readField();
    delete bin;

    if (!data.contains(0)) {
        qDebug() << "KLAIDA!" << data.keys();
    }

    if (name.toLower() == "createnotebook") {
        QString oldGuid = guid;
        loadFromData(data[0].value<hash>());

        QSqlQuery query;
        query.prepare("UPDATE notes SET notebookGuid=:notebookGuid WHERE notebookGuid=:oldGuid");
        query.bindValue(":notebookGuid", guid);
        query.bindValue(":oldGuid", oldGuid);
        query.exec();
        query.clear();

        query.prepare("UPDATE syncStatus SET value=:guid WHERE option=:option AND value=:oldGuid");
        query.bindValue(":guid", QString("notebook@%1").arg(guid));
        query.bindValue(":oldGuid", QString("notebook@%1").arg(oldGuid));
        query.bindValue(":option", "selNotebook");
        query.exec();
        query.clear();

        query.prepare("DELETE FROM notebooks WHERE guid=:oldGuid");
        query.bindValue(":oldGuid", oldGuid);
        query.exec();
    }
    else
        updateSequenceNum = data[0].toInt();

    toSQL();

    if (updateSequenceNum > 0)
        EdamProtocol::GetInstance()->getSyncEngine()->updateUSN(updateSequenceNum);

    QSqlQuery query;
    query.prepare("DELETE FROM notebookUpdates WHERE guid=:guid");
    query.bindValue(":guid", guid);
    query.exec();
}