init commit
This commit is contained in:
commit
a3392513e3
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
# build
|
||||
build/
|
||||
|
||||
# user files
|
||||
*.user
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "vendor/libsai"]
|
||||
path = vendor/libsai
|
||||
url = https://github.com/Wunkolo/libsai
|
14
CMakeLists.txt
Normal file
14
CMakeLists.txt
Normal file
|
@ -0,0 +1,14 @@
|
|||
project (pimageformats)
|
||||
|
||||
cmake_minimum_required (VERSION 3.9.5)
|
||||
|
||||
include (GNUInstallDirs)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(QT_MINIMUM_VERSION "5.10")
|
||||
|
||||
find_package(Qt5 ${QT_MINIMUM_VERSION} CONFIG REQUIRED Gui)
|
||||
|
||||
add_subdirectory(vendor/libsai)
|
||||
add_subdirectory(imageformats)
|
17
imageformats/CMakeLists.txt
Normal file
17
imageformats/CMakeLists.txt
Normal file
|
@ -0,0 +1,17 @@
|
|||
set (plugin pimg_sai)
|
||||
|
||||
set (PLUGIN_SOURCES
|
||||
sai_p.h
|
||||
sai.cpp
|
||||
)
|
||||
|
||||
# {{{ KCM style
|
||||
set(CMAKE_SHARED_MODULE_PREFIX "")
|
||||
unset(CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||
# }}}
|
||||
|
||||
add_library(${plugin} MODULE ${PLUGIN_SOURCES})
|
||||
set_property(TARGET ${plugin} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS "sai.json")
|
||||
set_target_properties(${plugin} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/imageformats")
|
||||
target_link_libraries(${plugin} Qt5::Gui sai)
|
61
imageformats/sai.cpp
Normal file
61
imageformats/sai.cpp
Normal file
|
@ -0,0 +1,61 @@
|
|||
#include "sai_p.h"
|
||||
|
||||
#include "sai.hpp"
|
||||
|
||||
SAIHandler::SAIHandler()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool SAIHandler::canRead() const
|
||||
{
|
||||
if (canRead(device())) {
|
||||
setFormat("sai");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SAIHandler::read(QImage *image)
|
||||
{
|
||||
Q_UNUSED(image)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SAIHandler::write(const QImage &image)
|
||||
{
|
||||
Q_UNUSED(image)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SAIHandler::canRead(QIODevice *device)
|
||||
{
|
||||
if (!device) {
|
||||
qWarning("SAIHandler::canRead() called with no device");
|
||||
return false;
|
||||
}
|
||||
|
||||
// FIXME: check
|
||||
return true;
|
||||
}
|
||||
|
||||
QImageIOPlugin::Capabilities SAIPlugin::capabilities(QIODevice *device, const QByteArray &format) const
|
||||
{
|
||||
if (!format.isEmpty()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!device->isOpen()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return Capabilities(CanRead);
|
||||
}
|
||||
|
||||
QImageIOHandler *SAIPlugin::create(QIODevice *device, const QByteArray &format) const
|
||||
{
|
||||
QImageIOHandler *handler = new SAIHandler;
|
||||
handler->setDevice(device);
|
||||
handler->setFormat(format);
|
||||
return handler;
|
||||
}
|
4
imageformats/sai.json
Normal file
4
imageformats/sai.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"Keys": [ "sai" ],
|
||||
"MimeTypes": []
|
||||
}
|
25
imageformats/sai_p.h
Normal file
25
imageformats/sai_p.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
#include <QImageIOPlugin>
|
||||
|
||||
class SAIHandler : public QImageIOHandler
|
||||
{
|
||||
public:
|
||||
SAIHandler();
|
||||
|
||||
bool canRead() const override;
|
||||
bool read(QImage *image) override;
|
||||
bool write(const QImage &image) override;
|
||||
|
||||
static bool canRead(QIODevice *device);
|
||||
};
|
||||
|
||||
class SAIPlugin : public QImageIOPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "sai.json")
|
||||
|
||||
public:
|
||||
Capabilities capabilities(QIODevice *device, const QByteArray &format) const override;
|
||||
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override;
|
||||
};
|
1
vendor/libsai
vendored
Submodule
1
vendor/libsai
vendored
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 607ec7acb817b52a4d2bc2682fcd07c0a78b4f19
|
Loading…
Reference in New Issue
Block a user