├── .gitignore ├── README.md ├── common-config.pri ├── qtraw.pro ├── src ├── .gitignore ├── datastream.cpp ├── datastream.h ├── main.cpp ├── raw-io-handler.cpp ├── raw-io-handler.h ├── raw.desktop ├── raw.json └── src.pro └── tests ├── .gitignore ├── qtraw-test.cpp ├── qtraw-test.h ├── testimage.arw └── tests.pro /.gitignore: -------------------------------------------------------------------------------- 1 | *.moc 2 | *.o 3 | Makefile 4 | moc_*.cpp 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Moved to https://gitlab.com/mardy/qtraw 2 | ======================================= 3 | 4 | This repository is now read-only and won't be updated anymore. Please get 5 | QtRaw from [here](https://gitlab.com/mardy/qtraw). 6 | 7 | QtRaw 8 | ===== 9 | 10 | Qt image plugin for loading raw files, via libraw. Once installed, it enables 11 | all Qt applications to load raw files produced by most digital cameras. 12 | 13 | The code is licensed udner the GPL v3 licence. If you need to distribute it 14 | under a different license, please contact me at info@mardy.it 15 | 16 | INSTALL 17 | ======= 18 | 19 | The QtRaw plugin depends on Qt and libraw. In order to build it, make sure you 20 | have the necessary development packages installed. Under Ubuntu, this can be 21 | achieved by running these commands: 22 | 23 | sudo apt-get install libraw-dev qtbase5-dev 24 | 25 | for building with Qt 5, or 26 | 27 | sudo apt-get install libraw-dev libqt4-dev 28 | 29 | for building with Qt 4. 30 | Alternatively, you can find the libraw source code at 31 | http://www.libraw.org/download 32 | 33 | 34 | Once the dependencies are set up, the following commands will build and install 35 | the plugin into your system: 36 | 37 | qmake 38 | make 39 | sudo make install 40 | 41 | If everything worked correctly, all Qt applications should be able to load and 42 | display raw camera files. 43 | -------------------------------------------------------------------------------- /common-config.pri: -------------------------------------------------------------------------------- 1 | PROJECT_NAME = qtraw 2 | PROJECT_VERSION = 1.1 3 | 4 | TOP_SRC_DIR = $$PWD 5 | TOP_BUILD_DIR = $${TOP_SRC_DIR}/$(BUILD_DIR) 6 | 7 | INSTALL_PREFIX = /usr 8 | 9 | isEmpty(PREFIX) { 10 | message("====") 11 | message("==== NOTE: To override the installation path run: `qmake PREFIX=/custom/path'") 12 | message("==== (current installation path is `$${INSTALL_PREFIX}')") 13 | } else { 14 | INSTALL_PREFIX = $${PREFIX} 15 | message("====") 16 | message("==== install prefix set to `$${INSTALL_PREFIX}'") 17 | } 18 | 19 | 20 | INSTALL_LIBDIR = $${INSTALL_PREFIX}/lib 21 | 22 | # default library directory can be overriden by defining LIBDIR when 23 | # running qmake 24 | isEmpty(LIBDIR) { 25 | message("====") 26 | message("==== NOTE: To override the library installation path run: `qmake LIBDIR=/custom/path'") 27 | message("==== (current installation path is `$${INSTALL_LIBDIR}')") 28 | } else { 29 | INSTALL_LIBDIR = $${LIBDIR} 30 | message("====") 31 | message("==== library install path set to `$${INSTALL_LIBDIR}'") 32 | } 33 | 34 | 35 | INSTALL_KDEDIR = $${PREFIX} 36 | 37 | isEmpty(KDEDIR) { 38 | message("====") 39 | message("==== NOTE: To override the KDE installation path run: `qmake KDEDIR=/custom/path'") 40 | message("==== (current installation path is `$${INSTALL_KDEDIR}')") 41 | } else { 42 | INSTALL_KDEDIR = $${KDEDIR} 43 | message("====") 44 | message("==== KDE install path set to `$${INSTALL_KDEDIR}'") 45 | } 46 | -------------------------------------------------------------------------------- /qtraw.pro: -------------------------------------------------------------------------------- 1 | include(common-config.pri) 2 | 3 | TEMPLATE = subdirs 4 | SUBDIRS = \ 5 | src \ 6 | tests 7 | 8 | DISTNAME = $${PROJECT_NAME}-$${PROJECT_VERSION} 9 | dist.commands = "git archive --format=tar --prefix=$${DISTNAME}/ HEAD | bzip2 -9 > $${DISTNAME}.tar.bz2" 10 | QMAKE_EXTRA_TARGETS += dist 11 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | imageformats/ 2 | -------------------------------------------------------------------------------- /src/datastream.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Alberto Mardegan 3 | * 4 | * This file is part of QtRaw. 5 | * 6 | * QtRaw is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * QtRaw is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with QtRaw. If not, see . 18 | */ 19 | 20 | #include "datastream.h" 21 | 22 | #include 23 | #include 24 | 25 | Datastream::Datastream(QIODevice *device): 26 | m_device(device) 27 | { 28 | } 29 | 30 | Datastream::~Datastream() 31 | { 32 | } 33 | 34 | int Datastream::valid() 35 | { 36 | return m_device->isReadable(); 37 | } 38 | 39 | int Datastream::read(void *ptr, size_t size, size_t nmemb) 40 | { 41 | return int(m_device->read((char *)ptr, size * nmemb)); 42 | } 43 | 44 | int Datastream::seek(INT64 offset, int whence) 45 | { 46 | qint64 pos; 47 | switch (whence) { 48 | case SEEK_SET: 49 | pos = offset; 50 | break; 51 | case SEEK_CUR: 52 | pos = m_device->pos() + offset; 53 | break; 54 | case SEEK_END: 55 | pos = m_device->size(); 56 | break; 57 | default: 58 | return -1; 59 | } 60 | 61 | if (pos < 0) pos = 0; 62 | return m_device->seek(pos) ? 0 : -1; 63 | } 64 | 65 | INT64 Datastream::tell() 66 | { 67 | return m_device->pos(); 68 | } 69 | 70 | INT64 Datastream::size() 71 | { 72 | return m_device->size(); 73 | } 74 | 75 | int Datastream::get_char() 76 | { 77 | char c; 78 | return m_device->getChar(&c) ? (unsigned char)c : -1; 79 | } 80 | 81 | char *Datastream::gets(char *s, int n) 82 | { 83 | return m_device->readLine(s, n) >= 0 ? s : NULL; 84 | } 85 | 86 | int Datastream::scanf_one(const char *fmt, void *val) 87 | { 88 | QTextStream stream(m_device); 89 | /* This is only used for %d or %f */ 90 | if (qstrcmp(fmt, "%d") == 0) { 91 | int d; 92 | stream >> d; 93 | *(static_cast(val)) = d; 94 | } else if (qstrcmp(fmt, "%f") == 0) { 95 | float f; 96 | stream >> f; 97 | *(static_cast(val)) = f; 98 | } else { 99 | return 0; 100 | } 101 | return (stream.status() == QTextStream::Ok) ? 1 : EOF; 102 | } 103 | 104 | int Datastream::eof() 105 | { 106 | return m_device->atEnd(); 107 | } 108 | 109 | void *Datastream::make_jas_stream() 110 | { 111 | return NULL; 112 | } 113 | -------------------------------------------------------------------------------- /src/datastream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Alberto Mardegan 3 | * 4 | * This file is part of QtRaw. 5 | * 6 | * QtRaw is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * QtRaw is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with QtRaw. If not, see . 18 | */ 19 | 20 | #ifndef DATASTREAM_H 21 | #define DATASTREAM_H 22 | 23 | #include 24 | 25 | #include 26 | 27 | class QIODevice; 28 | 29 | class Datastream: public LibRaw_abstract_datastream 30 | { 31 | public: 32 | Datastream(QIODevice *device); 33 | ~Datastream(); 34 | 35 | // reimplemented virtual methods: 36 | virtual int valid(); 37 | virtual int read(void *ptr, size_t size, size_t nmemb); 38 | virtual int seek(INT64 offset, int whence); 39 | virtual INT64 tell(); 40 | virtual INT64 size(); 41 | virtual int get_char(); 42 | virtual char *gets(char *s, int n); 43 | virtual int scanf_one(const char *fmt, void *val); 44 | virtual int eof(); 45 | virtual void *make_jas_stream(); 46 | 47 | private: 48 | QIODevice *m_device; 49 | }; 50 | 51 | #endif // DATASTREAM_H 52 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Alberto Mardegan 3 | * 4 | * This file is part of QtRaw. 5 | * 6 | * QtRaw is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * QtRaw is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with QtRaw. If not, see . 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "raw-io-handler.h" 26 | 27 | class RawPlugin: public QImageIOPlugin 28 | { 29 | Q_OBJECT 30 | #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) 31 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "raw.json") 32 | #endif 33 | 34 | public: 35 | QStringList keys() const; 36 | Capabilities capabilities(QIODevice *device, 37 | const QByteArray &format) const; 38 | QImageIOHandler *create(QIODevice *device, 39 | const QByteArray &format = QByteArray()) const; 40 | }; 41 | 42 | QStringList RawPlugin::keys() const 43 | { 44 | return QStringList() << 45 | QLatin1String("crw") << QLatin1String("cr2") << 46 | QLatin1String("arw") << 47 | QLatin1String("nef") << 48 | QLatin1String("raf") << 49 | QLatin1String("dng"); 50 | } 51 | 52 | QImageIOPlugin::Capabilities 53 | RawPlugin::capabilities(QIODevice *device, const QByteArray &format) const 54 | { 55 | if (keys().contains(format) || 56 | format == "tif" || 57 | format == "tiff") 58 | return Capabilities(CanRead); 59 | if (!format.isEmpty()) 60 | return 0; 61 | 62 | Capabilities cap; 63 | if (device->isReadable() && RawIOHandler::canRead(device)) 64 | cap |= CanRead; 65 | return cap; 66 | } 67 | 68 | QImageIOHandler *RawPlugin::create(QIODevice *device, 69 | const QByteArray &format) const 70 | { 71 | RawIOHandler *handler = new RawIOHandler(); 72 | handler->setDevice(device); 73 | handler->setFormat(format); 74 | return handler; 75 | } 76 | 77 | #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) 78 | Q_EXPORT_PLUGIN2(qtraw, RawPlugin) 79 | #endif 80 | 81 | #include "main.moc" 82 | -------------------------------------------------------------------------------- /src/raw-io-handler.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Alberto Mardegan 3 | * 4 | * This file is part of QtRaw. 5 | * 6 | * QtRaw is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * QtRaw is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with QtRaw. If not, see . 18 | */ 19 | 20 | #include "datastream.h" 21 | #include "raw-io-handler.h" 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | class RawIOHandlerPrivate 30 | { 31 | public: 32 | RawIOHandlerPrivate(RawIOHandler *qq): 33 | raw(0), 34 | stream(0), 35 | q(qq) 36 | {} 37 | 38 | ~RawIOHandlerPrivate(); 39 | 40 | bool load(QIODevice *device); 41 | 42 | LibRaw *raw; 43 | Datastream *stream; 44 | QSize defaultSize; 45 | QSize scaledSize; 46 | mutable RawIOHandler *q; 47 | }; 48 | 49 | RawIOHandlerPrivate::~RawIOHandlerPrivate() 50 | { 51 | delete raw; 52 | raw = 0; 53 | delete stream; 54 | stream = 0; 55 | } 56 | 57 | bool RawIOHandlerPrivate::load(QIODevice *device) 58 | { 59 | if (device == 0) return false; 60 | 61 | device->seek(0); 62 | if (raw != 0) return true; 63 | 64 | stream = new Datastream(device); 65 | raw = new LibRaw; 66 | if (raw->open_datastream(stream) != LIBRAW_SUCCESS) { 67 | delete raw; 68 | raw = 0; 69 | delete stream; 70 | stream = 0; 71 | return false; 72 | } 73 | 74 | defaultSize = QSize(raw->imgdata.sizes.width, 75 | raw->imgdata.sizes.height); 76 | if (raw->imgdata.sizes.flip == 5 || raw->imgdata.sizes.flip == 6) { 77 | defaultSize.transpose(); 78 | } 79 | return true; 80 | } 81 | 82 | 83 | RawIOHandler::RawIOHandler(): 84 | d(new RawIOHandlerPrivate(this)) 85 | { 86 | } 87 | 88 | 89 | RawIOHandler::~RawIOHandler() 90 | { 91 | delete d; 92 | } 93 | 94 | 95 | bool RawIOHandler::canRead() const 96 | { 97 | if (canRead(device())) { 98 | setFormat("raw"); 99 | return true; 100 | } 101 | return false; 102 | } 103 | 104 | 105 | bool RawIOHandler::canRead(QIODevice *device) 106 | { 107 | if (!device) { 108 | return false; 109 | } 110 | RawIOHandler handler; 111 | return handler.d->load(device); 112 | } 113 | 114 | 115 | bool RawIOHandler::read(QImage *image) 116 | { 117 | if (!d->load(device())) return false; 118 | 119 | QSize finalSize = d->scaledSize.isValid() ? 120 | d->scaledSize : d->defaultSize; 121 | 122 | const libraw_data_t &imgdata = d->raw->imgdata; 123 | libraw_processed_image_t *output; 124 | if (finalSize.width() < imgdata.thumbnail.twidth || 125 | finalSize.height() < imgdata.thumbnail.theight) { 126 | qDebug() << "Using thumbnail"; 127 | d->raw->unpack_thumb(); 128 | output = d->raw->dcraw_make_mem_thumb(); 129 | } else { 130 | qDebug() << "Decoding raw data"; 131 | d->raw->unpack(); 132 | d->raw->dcraw_process(); 133 | output = d->raw->dcraw_make_mem_image(); 134 | } 135 | 136 | QImage unscaled; 137 | uchar *pixels = 0; 138 | if (output->type == LIBRAW_IMAGE_JPEG) { 139 | unscaled.loadFromData(output->data, output->data_size, "JPEG"); 140 | if (imgdata.sizes.flip != 0) { 141 | QTransform rotation; 142 | int angle = 0; 143 | if (imgdata.sizes.flip == 3) angle = 180; 144 | else if (imgdata.sizes.flip == 5) angle = -90; 145 | else if (imgdata.sizes.flip == 6) angle = 90; 146 | if (angle != 0) { 147 | rotation.rotate(angle); 148 | unscaled = unscaled.transformed(rotation); 149 | } 150 | } 151 | } else { 152 | int numPixels = output->width * output->height; 153 | int colorSize = output->bits / 8; 154 | int pixelSize = output->colors * colorSize; 155 | pixels = new uchar[numPixels * 4]; 156 | uchar *data = output->data; 157 | for (int i = 0; i < numPixels; i++, data += pixelSize) { 158 | if (output->colors == 3) { 159 | pixels[i * 4] = data[2 * colorSize]; 160 | pixels[i * 4 + 1] = data[1 * colorSize]; 161 | pixels[i * 4 + 2] = data[0]; 162 | } else { 163 | pixels[i * 4] = data[0]; 164 | pixels[i * 4 + 1] = data[0]; 165 | pixels[i * 4 + 2] = data[0]; 166 | } 167 | } 168 | unscaled = QImage(pixels, 169 | output->width, output->height, 170 | QImage::Format_RGB32); 171 | } 172 | 173 | if (unscaled.size() != finalSize) { 174 | // TODO: use quality parameter to decide transformation method 175 | *image = unscaled.scaled(finalSize, Qt::IgnoreAspectRatio, 176 | Qt::SmoothTransformation); 177 | } else { 178 | *image = unscaled; 179 | if (output->type == LIBRAW_IMAGE_BITMAP) { 180 | // make sure that the bits are copied 181 | uchar *b = image->bits(); 182 | Q_UNUSED(b); 183 | } 184 | } 185 | d->raw->dcraw_clear_mem(output); 186 | delete pixels; 187 | 188 | return true; 189 | } 190 | 191 | 192 | QVariant RawIOHandler::option(ImageOption option) const 193 | { 194 | switch(option) { 195 | case ImageFormat: 196 | return QImage::Format_RGB32; 197 | case Size: 198 | d->load(device()); 199 | return d->defaultSize; 200 | case ScaledSize: 201 | return d->scaledSize; 202 | default: 203 | break; 204 | } 205 | return QVariant(); 206 | } 207 | 208 | 209 | void RawIOHandler::setOption(ImageOption option, const QVariant & value) 210 | { 211 | switch(option) { 212 | case ScaledSize: 213 | d->scaledSize = value.toSize(); 214 | break; 215 | default: 216 | break; 217 | } 218 | } 219 | 220 | 221 | bool RawIOHandler::supportsOption(ImageOption option) const 222 | { 223 | switch (option) 224 | { 225 | case ImageFormat: 226 | case Size: 227 | case ScaledSize: 228 | return true; 229 | default: 230 | break; 231 | } 232 | return false; 233 | } 234 | -------------------------------------------------------------------------------- /src/raw-io-handler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Alberto Mardegan 3 | * 4 | * This file is part of QtRaw. 5 | * 6 | * QtRaw is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * QtRaw is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with QtRaw. If not, see . 18 | */ 19 | 20 | #ifndef RAW_IO_HANDLER_H 21 | #define RAW_IO_HANDLER_H 22 | 23 | #include 24 | 25 | class QImage; 26 | class QByteArray; 27 | class QIODevice; 28 | class QVariant; 29 | 30 | class RawIOHandlerPrivate; 31 | class RawIOHandler: public QImageIOHandler 32 | { 33 | public: 34 | RawIOHandler(); 35 | ~RawIOHandler(); 36 | 37 | virtual bool canRead() const; 38 | virtual bool read(QImage *image); 39 | static bool canRead(QIODevice *device); 40 | virtual QVariant option(ImageOption option) const; 41 | virtual void setOption(ImageOption option, const QVariant & value); 42 | virtual bool supportsOption(ImageOption option) const; 43 | 44 | private: 45 | RawIOHandlerPrivate *d; 46 | }; 47 | 48 | #endif // RAW_IO_HANDLER_H 49 | -------------------------------------------------------------------------------- /src/raw.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Service 3 | X-KDE-ServiceTypes=QImageIOPlugins 4 | X-KDE-ImageFormat=raw 5 | X-KDE-MimeType=image/x-sony-arw 6 | X-KDE-Read=true 7 | X-KDE-Write=false 8 | -------------------------------------------------------------------------------- /src/raw.json: -------------------------------------------------------------------------------- 1 | { 2 | "Keys": [ 3 | "crw", "cr2", 4 | "arw", 5 | "nef", 6 | "raf", 7 | "dng" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /src/src.pro: -------------------------------------------------------------------------------- 1 | include(../common-config.pri) 2 | 3 | TARGET = qtraw 4 | TEMPLATE = lib 5 | CONFIG += \ 6 | link_pkgconfig \ 7 | plugin 8 | DESTDIR = imageformats 9 | 10 | PKGCONFIG += \ 11 | libraw 12 | 13 | HEADERS += \ 14 | datastream.h \ 15 | raw-io-handler.h 16 | SOURCES += \ 17 | datastream.cpp \ 18 | main.cpp \ 19 | raw-io-handler.cpp 20 | OTHER_FILES += \ 21 | raw.json 22 | 23 | target.path += $$[QT_INSTALL_PLUGINS]/imageformats 24 | INSTALLS += target 25 | 26 | # For KDE, install a .desktop file with metadata about the loader 27 | kde_desktop.files = raw.desktop 28 | kde_desktop.path = $${INSTALL_KDEDIR}/share/kde4/services/qimageioplugins/ 29 | INSTALLS += kde_desktop 30 | -------------------------------------------------------------------------------- /tests/.gitignore: -------------------------------------------------------------------------------- 1 | qtraw-test 2 | -------------------------------------------------------------------------------- /tests/qtraw-test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Alberto Mardegan 3 | * 4 | * This file is part of QtRaw. 5 | * 6 | * QtRaw is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * QtRaw is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with QtRaw. If not, see . 18 | */ 19 | 20 | #include "qtraw-test.h" 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | void QtRawTest::initTestCase() 27 | { 28 | } 29 | 30 | void QtRawTest::cleanupTestCase() 31 | { 32 | } 33 | 34 | void QtRawTest::loadRaw() 35 | { 36 | QImage raw("testimage.arw"); 37 | QCOMPARE(raw.size(), QSize(4288, 2856)); 38 | } 39 | 40 | void QtRawTest::loadRawWithReader() 41 | { 42 | QImageReader reader("testimage.arw"); 43 | QCOMPARE(reader.size(), QSize(4288, 2856)); 44 | 45 | reader.setScaledSize(QSize(800,600)); 46 | QImage raw = reader.read(); 47 | QCOMPARE(raw.size(), QSize(800, 600)); 48 | } 49 | 50 | QTEST_MAIN(QtRawTest) 51 | -------------------------------------------------------------------------------- /tests/qtraw-test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Alberto Mardegan 3 | * 4 | * This file is part of QtRaw. 5 | * 6 | * QtRaw is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * QtRaw is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with QtRaw. If not, see . 18 | */ 19 | 20 | #ifndef QTRAW_TEST_H 21 | #define QTRAW_TEST_H 22 | 23 | #include 24 | 25 | class QtRawTest: public QObject 26 | { 27 | Q_OBJECT 28 | 29 | private Q_SLOTS: 30 | void initTestCase(); 31 | void cleanupTestCase(); 32 | 33 | void loadRaw(); 34 | void loadRawWithReader(); 35 | }; 36 | 37 | #endif /* QTRAW_TEST_H */ 38 | -------------------------------------------------------------------------------- /tests/testimage.arw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mardy/qtraw/adaba1d18ff19e47d2afb06b9642eb1c5eaba774/tests/testimage.arw -------------------------------------------------------------------------------- /tests/tests.pro: -------------------------------------------------------------------------------- 1 | include(../common-config.pri) 2 | 3 | TARGET = qtraw-test 4 | 5 | QT += \ 6 | testlib 7 | 8 | SOURCES += \ 9 | qtraw-test.cpp 10 | 11 | HEADERS += \ 12 | qtraw-test.h 13 | 14 | check.commands = "QT_PLUGIN_PATH=$${TOP_BUILD_DIR}/src ./qtraw-test" 15 | check.depends = qtraw-test 16 | QMAKE_EXTRA_TARGETS += check 17 | --------------------------------------------------------------------------------