diff --git a/src/app/script/image_spec_class.cpp b/src/app/script/image_spec_class.cpp index 11c5f9569..61b8fa71f 100644 --- a/src/app/script/image_spec_class.cpp +++ b/src/app/script/image_spec_class.cpp @@ -1,4 +1,5 @@ // Aseprite +// Copyright (c) 2018 Igara Studio S.A. // Copyright (C) 2018 David Capello // // This program is distributed under the terms of @@ -56,6 +57,14 @@ int ImageSpec_gc(lua_State* L) return 0; } +int ImageSpec_eq(lua_State* L) +{ + auto a = get_obj(L, 1); + auto b = get_obj(L, 2); + lua_pushboolean(L, *a == *b); + return 1; +} + int ImageSpec_get_colorMode(lua_State* L) { const auto spec = get_obj(L, 1); @@ -114,6 +123,7 @@ int ImageSpec_set_transparentColor(lua_State* L) const luaL_Reg ImageSpec_methods[] = { { "__gc", ImageSpec_gc }, + { "__eq", ImageSpec_eq }, { nullptr, nullptr } }; diff --git a/src/doc/image_spec.h b/src/doc/image_spec.h index 4ef3c41e0..417be84cb 100644 --- a/src/doc/image_spec.h +++ b/src/doc/image_spec.h @@ -60,6 +60,19 @@ namespace doc { m_height = sz.h; } + bool operator==(const ImageSpec& that) const { + return (m_colorMode == that.m_colorMode && + m_width == that.m_width && + m_height == that.m_height && + m_maskColor == that.m_maskColor && + ((!m_colorSpace && !that.m_colorSpace) || + (m_colorSpace && that.m_colorSpace && + m_colorSpace->nearlyEqual(*that.m_colorSpace)))); + } + bool operator!=(const ImageSpec& that) const { + return !operator==(that); + } + private: ColorMode m_colorMode; int m_width;