Skip to content

Commit

Permalink
Add iV_Image::compare_equal
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Sep 1, 2023
1 parent 7f201f5 commit 770d682
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/ivis_opengl/pieimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,3 +561,22 @@ bool iV_Image::convert_color_order(ColorOrder newOrder)
m_colorOrder = newOrder;
return true;
}

bool iV_Image::compare_equal(const iV_Image& other)
{
if (m_width != other.m_width || m_height != other.m_height || m_channels != other.m_channels)
{
return false;
}
if (m_colorOrder != other.m_colorOrder)
{
return false;
}
if ((m_bmp == nullptr || other.m_bmp == nullptr) && (m_bmp != other.m_bmp))
{
return false;
}

const size_t sizeOfBuffers = sizeof(unsigned char) * m_width * m_height * m_channels;
return memcmp(m_bmp, other.m_bmp, sizeOfBuffers) == 0;
}
2 changes: 2 additions & 0 deletions lib/ivis_opengl/pietypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ class iV_Image final : public iV_BaseImage

bool convert_color_order(ColorOrder newOrder);

bool compare_equal(const iV_Image& other);

private:
bool resizeInternal(const iV_Image& source, int output_w, int output_h, optional<int> alphaChannelOverride = nullopt);

Expand Down

0 comments on commit 770d682

Please sign in to comment.