Skip to content

Commit

Permalink
Merge pull request #45 from afichet/v0.6.1
Browse files Browse the repository at this point in the history
v0.6.1
  • Loading branch information
afichet authored Dec 9, 2023
2 parents 821d9c8 + fb9a0eb commit 4f3b278
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 28 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.5)

project(openexr-viewer
VERSION 0.6.0
VERSION 0.6.1
DESCRIPTION "Simple Viewer for OpenEXR files with detailed metadata display"
HOMEPAGE_URL "https://github.com/afichet/openexr-viewer"
LANGUAGES CXX
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2021, Alban Fichet
Copyright (c) 2021 - 2023, Alban Fichet
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Expand Down
2 changes: 1 addition & 1 deletion deploy/linux/openexr-viewer.desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Desktop Entry]
Type=Application
Version=0.6.0
Version=0.6.1
Name=OpenEXR Viewer
Comment=Viewer for OpenEXR images
Icon=openexr-viewer
Expand Down
1 change: 1 addition & 0 deletions deploy/linux/openexr-viewer.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
</description>
<launchable type="desktop-id">openexr-viewer.desktop</launchable>
<releases>
<release date="2023-12-09" version="0.6.1" />
<release date="2023-05-40" version="0.6.0" />
<release date="2022-04-04" version="0.5.2"/>
<release date="2021-09-11" version="0.5.1"/>
Expand Down
6 changes: 1 addition & 5 deletions src/model/framebuffer/FramebufferModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

FramebufferModel::FramebufferModel(QObject* parent)
: QObject(parent)
, m_pixelBuffer(nullptr)
, m_width(0)
, m_height(0)
, m_isImageLoaded(false)
Expand All @@ -59,7 +58,4 @@ QRect FramebufferModel::getDataWindow() const
return m_dataWindow;
}

FramebufferModel::~FramebufferModel()
{
delete[] m_pixelBuffer;
}
FramebufferModel::~FramebufferModel() {}
8 changes: 5 additions & 3 deletions src/model/framebuffer/FramebufferModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include <QObject>
#include <QRect>
#include <QVector>
#include <array>
#include <vector>

class FramebufferModel: public QObject
{
Expand Down Expand Up @@ -67,9 +67,11 @@ class FramebufferModel: public QObject
void loadFailed(QString message);

protected:
float* m_pixelBuffer;
QImage m_image;
std::vector<float> m_pixelBuffer;
QImage m_image;

// Right now, the width and height are defined as Vec2i in OpenEXR
// i.e. int type.
int m_width, m_height;

bool m_isImageLoaded;
Expand Down
35 changes: 22 additions & 13 deletions src/model/framebuffer/RGBFramebufferModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,23 @@ void RGBFramebufferModel::load(
m_displayWindow
= QRect(dispW.min.x, dispW.min.y, dispW_width, dispW_height);

// Check to avoid type overflow, width and height are 32bits int
// representing a 2 dimentional image. Can overflow the type when
// multiplied together.
// 0x1FFFFFFF is a save limit for 4 * 0x7FFFFFFF the max
// representable int since we need 4 channels.
// TODO: Use larger type when manipulating framebuffer
const uint64_t partial_size
= (uint64_t)m_width * (uint64_t)m_height;

if (partial_size > 0x1FFFFFFF) {
throw std::runtime_error(
"The total image size is too large. May be supported in a "
"future revision.");
}

m_pixelBuffer.resize(4 * m_width * m_height);

// Check if there is specific chromaticities tied to the color
// representation in this part.
const Imf::ChromaticitiesAttribute* c
Expand All @@ -93,8 +110,6 @@ void RGBFramebufferModel::load(
chromaticities = c->value();
}

m_pixelBuffer = new float[4 * m_width * m_height];

// Check if there is alpha channel
if (hasAlpha) {
std::string aLayer = m_parentLayer + "A";
Expand Down Expand Up @@ -190,12 +205,12 @@ void RGBFramebufferModel::load(

Imf::FrameBuffer framebuffer;

Imf::Rgba* buff1 = new Imf::Rgba[m_width * m_height];
Imf::Rgba* buff2 = new Imf::Rgba[m_width * m_height];
std::vector<Imf::Rgba> buff1(m_width * m_height);
std::vector<Imf::Rgba> buff2(m_width * m_height);

float* yBuffer = new float[m_width * m_height];
float* ryBuffer = new float[m_width / 2 * m_height / 2];
float* byBuffer = new float[m_width / 2 * m_height / 2];
std::vector<float> yBuffer(m_width * m_height);
std::vector<float> ryBuffer(m_width / 2 * m_height / 2);
std::vector<float> byBuffer(m_width / 2 * m_height / 2);

Imf::Slice ySlice = Imf::Slice::Make(
Imf::PixelType::FLOAT,
Expand Down Expand Up @@ -335,12 +350,6 @@ void RGBFramebufferModel::load(
m_pixelBuffer[4 * (y * m_width + x) + 2] = rgb.z;
}
}

delete[] yBuffer;
delete[] ryBuffer;
delete[] byBuffer;
delete[] buff1;
delete[] buff2;
}

break;
Expand Down
21 changes: 17 additions & 4 deletions src/model/framebuffer/YFramebufferModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,25 @@ void YFramebufferModel::load(Imf::MultiPartInputFile& file, int partId)
dispW_width / 2,
dispW_height / 2);

m_pixelBuffer = new float[m_width * m_height];
// Check to avoid type overflow, width and height are 32bits int
// representing a 2 dimentional image. Can overflow the type when
// multiplied together
// TODO: Use larger type when manipulating framebuffer
const uint64_t partial_size
= (uint64_t)m_width * (uint64_t)m_height;

if (partial_size > 0x7FFFFFFF) {
throw std::runtime_error(
"The total image size is too large. May be supported in "
"a future revision.");
}

m_pixelBuffer.resize(m_width * m_height);

// Luminance Chroma channels
graySlice = Imf::Slice::Make(
Imf::PixelType::FLOAT,
m_pixelBuffer,
m_pixelBuffer.data(),
datW,
sizeof(float),
m_width * sizeof(float),
Expand All @@ -112,11 +125,11 @@ void YFramebufferModel::load(Imf::MultiPartInputFile& file, int partId)
m_displayWindow
= QRect(dispW.min.x, dispW.min.y, dispW_width, dispW_height);

m_pixelBuffer = new float[m_width * m_height];
m_pixelBuffer.resize(m_width * m_height);

graySlice = Imf::Slice::Make(
Imf::PixelType::FLOAT,
m_pixelBuffer,
m_pixelBuffer.data(),
datW);
}

Expand Down

0 comments on commit 4f3b278

Please sign in to comment.