diff --git a/rawimage.cpp b/rawimage.cpp index 9462ba0..8dc8c25 100644 --- a/rawimage.cpp +++ b/rawimage.cpp @@ -1,12 +1,17 @@ #include "rawimage.h" -#include #include +#include +#ifndef NO_QT +#include #include #include #include -#include - using F16 = qfloat16; +#else +#include +using F16 = uint16_t; +#endif + int THUMB_SIZE = 128; int THUMB_SIZE_BORDER = 138; @@ -78,6 +83,7 @@ RawImage::RawImage(RawImage &&d) m_thumbAspect = d.m_thumbAspect; } +#ifndef NO_QT RawImage::RawImage(const QImage &img) { qDebug() << img; @@ -145,6 +151,7 @@ RawImage::RawImage(const QImage &img) } m_stats.m_stats = false; } +#endif const RawImage::Stats& RawImage::imageStats() const { @@ -439,7 +446,9 @@ void RawImage::convertToThumbnail() loop(out, reinterpret_cast(m_pixels.get()), 1.0f); break; default: +#ifndef NO_QT qWarning() << "FLOAT64 should not happend"; +#endif return; } @@ -922,11 +931,13 @@ bool RawImage::valid() const return m_width > 0 && m_height > 0; } +#ifndef NO_QT void RawImage::setICCProfile(const QByteArray &icc) { if(icc.size()) m_iccProfile = std::vector(icc.begin(), icc.end()); } +#endif void RawImage::setICCProfile(const LibXISF::ByteArray &icc) { @@ -973,12 +984,12 @@ void RawImage::convertTosRGB() } else { - qDebug() << "Failed to create color transform"; + //qDebug() << "Failed to create color transform"; } } else { - qDebug() << "Failed to open icc profile"; + //qDebug() << "Failed to open icc profile"; } cmsCloseProfile(inProfile); @@ -1022,13 +1033,13 @@ void RawImage::generateLUT() } else { - qDebug() << "Failed to create color transform"; + //qDebug() << "Failed to create color transform"; m_lut.clear(); } } else { - qDebug() << "Failed to open icc profile"; + //qDebug() << "Failed to open icc profile"; m_lut.clear(); } diff --git a/rawimage.h b/rawimage.h index 1e41dcc..6677a0d 100644 --- a/rawimage.h +++ b/rawimage.h @@ -7,7 +7,9 @@ #include #include #include +#ifndef NO_QT #include +#endif extern int THUMB_SIZE; extern int THUMB_SIZE_BORDER; @@ -83,7 +85,9 @@ public: RawImage(uint32_t w, uint32_t h, uint32_t ch, DataType type); RawImage(const RawImage &d); RawImage(RawImage &&d); +#ifndef NO_QT RawImage(const QImage &img); +#endif const RawImage::Stats& imageStats() const; void calcStats(); uint32_t width() const; @@ -116,7 +120,9 @@ public: static size_t typeSize(DataType type); std::vector split() const; bool valid() const; +#ifndef NO_QT void setICCProfile(const QByteArray &icc); +#endif void setICCProfile(const LibXISF::ByteArray &icc); void convertTosRGB(); void generateLUT(); diff --git a/thumbnailer/CMakeLists.txt b/thumbnailer/CMakeLists.txt new file mode 100644 index 0000000..ce3624e --- /dev/null +++ b/thumbnailer/CMakeLists.txt @@ -0,0 +1,26 @@ +option(BUILD_THUMBNAILER "Build generator of thumbnails" OFF) + +if(BUILD_THUMBNAILER) + if(WIN32) + add_library(tenmonthumbnailer SHARED + winmain.cpp + ../rawimage.cpp + ../rawimage_sse.cpp) + + target_compile_definitions(tenmonthumbnailer PRIVATE NO_QT) + target_include_directories(tenmonthumbnailer PRIVATE ../libXISF) + target_link_libraries(tenmonthumbnailer PRIVATE ${LCMS2_LIB} XISF) + else(WIN32) + qt_add_executable(tenmonthumbnailer + main.cpp + ../rawimage.cpp + ../rawimage_sse.cpp + ../loadimage.cpp + ../imageinfodata.cpp) + + target_link_libraries(tenmonthumbnailer PRIVATE Qt6::Core Qt6::Gui ${EXIF_LIB} ${FITS_LIB} ${RAW_LIB} ${WCS_LIB} ${LCMS2_LIB} XISF) + + target_include_directories(tenmonthumbnailer PRIVATE ../libXISF) + endif(WIN32) +endif(BUILD_THUMBNAILER) + diff --git a/thumbnailer/main.cpp b/thumbnailer/main.cpp new file mode 100644 index 0000000..f67f3ec --- /dev/null +++ b/thumbnailer/main.cpp @@ -0,0 +1,48 @@ +#include +#include +#include "../rawimage.h" +#include "../loadimage.h" + +bool OpenGLES = false; + +int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + + QCommandLineParser parser; + parser.addOption({{"s", "size"}, "Size of the thumbnail in pixels (default: 128)", "size", "128"}); + parser.addPositionalArgument("input", "Input image file"); + parser.addPositionalArgument("output", "Output image file"); + parser.addHelpOption(); + + parser.process(a); + + QStringList args = parser.positionalArguments(); + + if(args.size() < 2) + return 1; + + QString input = args[0]; + QString output = args[1]; + + ImageInfoData info; + std::shared_ptr rawImage; + if(!loadImage(input, info, rawImage)) + return 1; + + if(!rawImage) + return 2; + + rawImage->convertToType(RawImage::UINT8); + + QImage img((const uchar*)rawImage->data(), rawImage->width(), rawImage->height(), QImage::Format_RGBA8888); + bool ok = false; + int size = parser.value("s").toInt(&ok); + if(!ok)size = 128; + img = img.scaled(size, size, Qt::KeepAspectRatio); + img.save(output, "png"); + + //rawImage->convertTosRGB(); + + return 0; +} diff --git a/thumbnailer/winmain.cpp b/thumbnailer/winmain.cpp new file mode 100644 index 0000000..9d64f18 --- /dev/null +++ b/thumbnailer/winmain.cpp @@ -0,0 +1 @@ +bool OpenGLES = false;