Skip to content

Add in-memory QImage support to QtImageReader - #1111

Open
rajeshgk wants to merge 1 commit into
OpenShot:developfrom
rajeshgk:feature/qt-image-buffer-reader
Open

rajeshgk wants to merge 1 commit into
OpenShot:developfrom
rajeshgk:feature/qt-image-buffer-reader

Conversation

@rajeshgk

Copy link
Copy Markdown

Summary

Add support for constructing QtImageReader directly from an
in-memory QImage, without requiring an intermediate image file.

Fixes #560

Motivation

Qt and QML applications can generate images dynamically, including
text, graphics, and overlays.

Previously, these images needed to be saved to disk before they
could be loaded by QtImageReader.

This enhancement allows applications to supply a QImage directly.

Implementation

  • Add an explicit QtImageReader(const QImage&) constructor.
  • Retain an independent copy of the source image.
  • Support normal Open(), Close(), and reopen operations.
  • Preserve alpha transparency.
  • Provide separate QImage objects for memory-backed frames.
  • Use Qt implicit sharing and copy-on-write semantics.
  • Reject null QImage input.
  • Preserve existing file-backed and SVG reader behavior.

Tests

All 13 QtImageReader tests pass:

  • 6 existing regression tests
  • 7 new in-memory image tests

New tests cover:

  • In-memory construction
  • Alpha transparency
  • Source-image independence
  • Repeated frame retrieval
  • Close/reopen lifecycle
  • Null-image rejection
  • Frame isolation

Test command:

ctest --test-dir build-issue560-gcc15 \
  -R QtImageReader --output-on-failure

Result:

100% tests passed, 0 tests failed out of 13

Serialization

Memory-backed images are transient.

Existing JSON serialization remains path-based and does not
serialize in-memory pixel data.

Applications requiring persistent project serialization should
use file-backed readers.

This limitation is documented in the public constructor API.

Compatibility

Existing file-backed QtImageReader behavior is preserved.

No changes to the public file-backed constructor are required.

@rajeshgk

Copy link
Copy Markdown
Author

Hello OpenShot maintainers,

I would appreciate a review of PR #1111, which introduces
in-memory QImage support to QtImageReader.

The implementation has been committed and tested locally,
and the available Codacy static analysis check is passing.

I have also completed a follow-up QtPaintReader implementation
that provides callback-driven frame generation, including
eight passing unit tests.

The follow-up is currently available as a stacked PR in my fork:
rajeshgk#1

I intend to submit QtPaintReader upstream separately after
the QtImageReader changes have been integrated.

Please let me know if any changes, additional tests, or
documentation would be helpful.

Thank you for your time and consideration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to burn a Qt type to video?

1 participant