Exemplo n.º 1
0
void ImageDocument::setContents(const ImageContents &contents)
{
    Q_D(ImageDocument);

    if (contents.isNull()) {
        clear();
        return;
    }

    const auto header = contents.header();
    d->type = header.type();
    d->size = header.size();
    d->imageFormat = header.imageFormat();
    d->imageCount = header.imageCount();
    d->mipmapCount = header.mipmapCount();
    d->frameDelay = header.frameDelay();
    d->loopCount = header.loopCount();
    for (int index = 0; index < d->imageCount; ++index) {
        for (int level = 0; level < d->mipmapCount; ++level) {
            auto image = contents.image(index, level);
            std::unique_ptr<ImageDocumentItem> item(new ImageDocumentItem(this));
            item->setSize(image.size());
            item->setImage(image);
            d->items[ImageDocumentPrivate::ImageIndex(index, level)] = std::move(item);
        }
    }

    emit contentsChanged();
}
Exemplo n.º 2
0
bool DefaultHandler::write(const ImageContents &contents, const WriteOptions &options)
{
    Q_UNUSED(options);
    QImageWriter writer(device(), mimeTypeToFormat(mimeType()));
    const bool ok = writer.write(contents.image());
    if (!ok)
        return false;

    return true;
}
Exemplo n.º 3
0
int main(int argc, char *argv[])
{
    ImageIO reader("image.png");
    auto result = reader.read();
    ImageIOResult ok = result.first;
    if (!ok) {
        qWarning() << "Error reading image:" << ok.toString();
        return 1;
    }
    ImageContents contents = result.second;
    handleImage(contents.image());
    return 0;
}