Git Product home page Git Product logo

qtapng's Introduction

QtApng

apng image plugin for Qt to support animated PNGs

CI build Codacy Badge AUR

Features

Enable the usage of apng images with Qt. The plugin adds the apng format as a new format for any Qt application, and thus supports loading of apng images via QMovie, AnimatedImage and other types.

Requirements

To build the plugin, libpng with the apng patch applied is required. By default the libpng provided by pkg-config is used for unix-like systems. If the library is not available, the project will compile a static library of libpng and embed it into the plugin. You can force this behaviour by running qmake with CONFIG += libpng_static

Embedded libpng/zlib

The project comes with a version of zlib and libpng (with the apng patch). They can be found in the src/3rdparty subfolder. They are automatically compiled into static libraries and used to link the apng plugin when neccessary. Please note that both libraries are compiled without any optimizations for architecture etc. If you wish to have those features, you can replace those two by your own versions.

Project Version License Project page
zlib 1.2.11 zlib-license https://www.zlib.net/
libpng 1.6.37 libpng-license http://www.libpng.org/pub/png/libpng.html
apng patch 1.6.37 libpng-license https://sourceforge.net/projects/libpng-apng/

Download/Installation

  1. Package Managers: The library is available via:
  2. Simply add my repository to your Qt MaintenanceTool (Image-based How-To here: Add custom repository):
    1. Start the MaintenanceTool from the commandline using /path/to/MaintenanceTool --addTempRepository <url> with one of the following urls (GUI-Method is currently broken, see QTIFW-1156) - This must be done every time you start the tool:
    2. A new entry appears under all supported Qt Versions (e.g. Qt > Qt 5.11 > Skycoder42 Qt modules)
    3. You can install either all of my modules, or select the one you need: Qt Apng Image Plugin
    4. Continue the setup and thats it! you can now use the module for all of your installed Kits for that Qt
  3. Download the compiled modules from the release page. Note: You will have to add the correct ones yourself and may need to adjust some paths to fit your installation! In addition to that, you will have to download the modules this one depends on as well. See Section "Requirements" below.
  4. Build it yourself! Note: This requires all build an runtime dependencies to be available (See Section "Requirements" below). If you don't have/need cmake, you can ignore the related warnings. To automatically build and install to your Qt installation, run:
    • Download the sources. Either use git clone or download from the releases. If you choose the second option, you have to manually create a folder named .git in the projects root directory, otherwise the build will fail.
    • qmake
    • make (If you want the tests/examples/etc. run make all)
    • make install

Usage

Simply use the default Qt classes like QImageReader, QMovie etc. and open the apng files just like you would open normal images/animations (like gif files)

Format Detection: Since the png format is already used by Qt, *.png files will not use the plugin. To load a png as animated, you can either rename the file to *.apng, or set the format explicitly

QMovie movie("path/to/image.png", "apng");

qtapng's People

Contributors

blumia avatar jurplel avatar omnitroid avatar skycoder42 avatar wolverindev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

qtapng's Issues

I'm using QT6

Hello author, I am using QT6 and I am very confused about how to run it correctly. Thank you very much for your help

maxSize argument exceeds QByteArray size limit

I built the qapng.dll from the source.
Env: msvc 2017 32bit . Qt5.15.0 beta and Qt5.14.0.

But when I am trying to read a apng. I got
QIODevice::read (QFile, "...\examples\apng\sample\sample.apng"): maxSize argument exceeds QByteArray size limit

Is there any way to solve this?

Thanks~

Incorrect output of nextImageDelay()

nextImageDelay() is supposed to return "the number of milliseconds to wait until reading the next image" (docs), so that it works with QMovie.

However, one of our developers is reporting that instead, ApngImageHandler is returning the delay of the next frame and the next next frame, instead of the delay of the current frame and the next frame.

I'll follow this issue up with a minimal example to help you reproduce the issue.

Transparency problem?

It seems apngs with transparent background are not rendered properly. The moving area is updated but the unmoving transparent area is shown in a black color, as can be observed in this example file.

Could not build library

Hello,
i tried to build your library on ubuntu 16.04 and for some reasons it failed.
My little command log:

Reading /home/wolverindev/cgit/qapng/src/src.pro
 Reading /home/wolverindev/cgit/qapng/src/plugins/plugins.pro
/home/wolverindev/cgit/qapng/src/plugins/plugins.pro:4: 'qtConfig' is not a recognized test function.
Reading /home/wolverindev/cgit/qapng/examples/examples.pro
 Reading /home/wolverindev/cgit/qapng/examples/apng/apng.pro
  Reading /home/wolverindev/cgit/qapng/examples/apng/sample/sample.pro
Reading /home/wolverindev/cgit/qapng/tests/tests.pro
 Reading /home/wolverindev/cgit/qapng/tests/auto/auto.pro
  Reading /home/wolverindev/cgit/qapng/tests/auto/cmake/cmake.pro
  Reading /home/wolverindev/cgit/qapng/tests/auto/apng/apng.pro
   Reading /home/wolverindev/cgit/qapng/tests/auto/apng/apngPlugin/apngPlugin.pro
wolverindev@WolverinDEV:~/cgit/qapng$ make
cd src/ && ( test -e Makefile || /usr/lib/x86_64-linux-gnu/qt5/bin/qmake /home/wolverindev/cgit/qapng/src/src.pro -o Makefile ) && make -f Makefile 
make[1]: Entering directory '/home/wolverindev/cgit/qapng/src'
cd plugins/ && ( test -e Makefile || /usr/lib/x86_64-linux-gnu/qt5/bin/qmake /home/wolverindev/cgit/qapng/src/plugins/plugins.pro -o Makefile ) && make -f Makefile 
make[2]: Entering directory '/home/wolverindev/cgit/qapng/src/plugins'
make[2]: Nothing to be done for 'first'.
make[2]: Leaving directory '/home/wolverindev/cgit/qapng/src/plugins'
make[1]: Leaving directory '/home/wolverindev/cgit/qapng/src'
cd examples/ && ( test -e Makefile || /usr/lib/x86_64-linux-gnu/qt5/bin/qmake /home/wolverindev/cgit/qapng/examples/examples.pro -o Makefile ) && make -f Makefile 
make[1]: Entering directory '/home/wolverindev/cgit/qapng/examples'
cd apng/ && ( test -e Makefile || /usr/lib/x86_64-linux-gnu/qt5/bin/qmake /home/wolverindev/cgit/qapng/examples/apng/apng.pro -o Makefile ) && make -f Makefile 
make[2]: Entering directory '/home/wolverindev/cgit/qapng/examples/apng'
cd sample/ && ( test -e Makefile || /usr/lib/x86_64-linux-gnu/qt5/bin/qmake /home/wolverindev/cgit/qapng/examples/apng/sample/sample.pro -o Makefile ) && make -f Makefile 
make[3]: Entering directory '/home/wolverindev/cgit/qapng/examples/apng/sample'
g++ -c -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -O2 -fno-exceptions -Wall -W -D_REENTRANT -fPIC -DQT_NO_TSLIB -DQT_DEPRECATED_WARNINGS -DQT_ASCII_CAST_WARNINGS -DOUTDIR=\"/home/wolverindev/cgit/qapng/examples/apng/sample/\" -DPLGDIR=\"/usr/lib/x86_64-linux-gnu/qt5/plugins/\" -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I.moc -isystem /usr/include/libdrm -I.uic -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -o .obj/main.o main.cpp
In file included from main.cpp:1:0:
widget.h:15:2: warning: identifier ‘nullptr’ is a keyword in C++11 [-Wc++0x-compat]
  explicit Widget(QWidget *parent = nullptr);
  ^
widget.h:15:36: error: ‘nullptr’ was not declared in this scope
  explicit Widget(QWidget *parent = nullptr);
                                    ^
main.cpp: In function ‘void ln_plugin()’:
main.cpp:11:2: warning: lambda expressions only available with -std=c++11 or -std=gnu++11
  });
  ^
main.cpp: In function ‘int main(int, char**)’:
main.cpp:18:9: error: call to ‘Widget::Widget(QWidget*)’ uses the default argument for parameter 1, which is not yet defined
  Widget w;
         ^
Makefile:331: recipe for target '.obj/main.o' failed
make[3]: *** [.obj/main.o] Error 1
make[3]: Leaving directory '/home/wolverindev/cgit/qapng/examples/apng/sample'
Makefile:42: recipe for target 'sub-sample-make_first' failed
make[2]: *** [sub-sample-make_first] Error 2
make[2]: Leaving directory '/home/wolverindev/cgit/qapng/examples/apng'
Makefile:42: recipe for target 'sub-apng-make_first' failed
make[1]: *** [sub-apng-make_first] Error 2
make[1]: Leaving directory '/home/wolverindev/cgit/qapng/examples'
Makefile:69: recipe for target 'sub-examples-make_first' failed
make: *** [sub-examples-make_first] Error 2

QMake version:

QMake version 3.0
Using Qt version 5.5.1 in /usr/lib/x86_64-linux-gnu

G++ version:

Using built-in specs.
COLLECT_GCC=/usr/bin/g++-5.real
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.1-2ubuntu1~16.04' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.1 20160904 (Ubuntu 5.4.1-2ubuntu1~16.04) 

I home you're able to help me out.

Best regards
WolverinDEV

not build for qt5.13.2

This library is very useful. But compile is intricate for me.
Could you please rebuild it for qt5.13.2? Thank you.

How about referring to my implementation?

Hi,

Your apng plugin has been modified and used as part of QuickViewer.

As I am satisfied with my modifications, it will already be older than your implementation.

I read a bit of your latest implementation, but I decided to inform you about something better to say about 2 points.

  1. Your apng format check contains unnecessary processing and is inefficient
    • ApngImageHandler::option(QImageIOHandler::Animation)
    • We only need to search for png signatures and acTL chunks, and then shouldn't do anything else.
    • Since the apng plugin contains inefficient and unnecessary operations to open a normal png image, when it is confirmed that there is no animation, it is necessary to switch to the usual png ImageIOHandler.
  2. Your private class implementation is not a Qt standard implementation.
    • Declare a class with 'ApngImageHandlerPrivate' etc. followed by 'Private' in the header file and write a pointer with the variable name of 'd' in the private variable.
    • The private class is synchronized with the lifetime of the class of the main body, it should be new in the constructor and deleted in the destructor.
    • When inheriting from QImageIOHandler, it is necessary to check the file format with the options () method, but unnecessary const constraints are attached due to mistakes in the design of Qt, and it is impossible to avoid the workaround by private class.

The above is just my opinion, so you do not have to follow it.
I will open up my current implementation so please refer to it.

https://github.com/kanryu/qapng_Skycoder42

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.