Skip to content

Commit

Permalink
updated Image class a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacey committed Sep 26, 2023
1 parent 717f379 commit eb3531c
Showing 1 changed file with 25 additions and 31 deletions.
56 changes: 25 additions & 31 deletions src/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,25 @@
#include "Image.h"
#include "NGLassert.h"
#include "pystring.h"
#if defined(USEQIMAGE)
#include <QtGui/QImage>
#endif
#if defined(USEOIIO)
#include <OpenImageIO/imageio.h>
#endif

#if defined(USEBUILTINIMAGE)
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
enum class ImageLibrary : char { QImage, OIIO, BuiltIn };

#include "../3rdparty/stb_image.h"
#include "../3rdparty/stb_image_write.h"
#if defined(USEQIMAGE)
const ImageLibrary g_imageLib = ImageLibrary::QImage;
#include <QtGui/QImage>
#elif defined(USEOIIO)
const ImageLibrary g_imageLib = ImageLibrary::OIIO;
#include <OpenImageIO/imageio.h>
#elif defined(USEBUILTINIMAGE)
const ImageLibrary g_imageLib = ImageLibrary::BuiltIn;
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION

#include "../3rdparty/stb_image.h"
#include "../3rdparty/stb_image_write.h"
#endif


#include <iostream>

namespace ngl
Expand All @@ -45,19 +49,18 @@ namespace ngl

void Image::info()
{
#if defined(USEOIIO)
NGLMessage::addMessage("Using OpenImageIO");
#endif

#if defined(USEQIMAGE)
if constexpr (g_imageLib == ImageLibrary::QImage)
{
NGLMessage::addMessage("Using QImage");

#endif

#if defined(USEBUILTINIMAGE)
}
else if constexpr (g_imageLib == ImageLibrary::OIIO)
{
NGLMessage::addMessage("Using OpenImageIO");
}
else if constexpr (g_imageLib == ImageLibrary::BuiltIn)
{
NGLMessage::addMessage("Using built in stb-image");
#endif

}
NGLMessage::addMessage("Image Info END");
}

Expand Down Expand Up @@ -153,15 +156,6 @@ bool Image::save(std::string_view _fname,bool _flipY) const noexcept
}

#if defined(USEQIMAGE)
// QImage::Format qformat
// if(m_channels == 4)
// {
// qformat = QImage::Format::Format_RGBA8888;
// }
// else
// {
// qformat = QImage::Format::Format_RGB888;
// }
QImage image(m_data.get(), m_width, m_height, m_channels==4 ? QImage::Format::Format_RGBA8888 : QImage::Format::Format_RGB888);
image = image.mirrored(false, _flipY);
image.save(_fname.data());
Expand Down

0 comments on commit eb3531c

Please sign in to comment.