mirror of https://github.com/KLayout/klayout.git
Renamed lay::Image to lay::PixelBuffer
This commit is contained in:
parent
17cbcc2877
commit
f51fac5f0f
|
|
@ -20,16 +20,16 @@
|
|||
|
||||
*/
|
||||
|
||||
#include "layImage.h"
|
||||
#include "layPixelBuffer.h"
|
||||
#include "tlAssert.h"
|
||||
|
||||
namespace lay
|
||||
{
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
// Image implementation
|
||||
// PixelBuffer implementation
|
||||
|
||||
Image::Image (unsigned int w, unsigned int h, lay::color_t *data)
|
||||
PixelBuffer::PixelBuffer (unsigned int w, unsigned int h, lay::color_t *data)
|
||||
: m_data ()
|
||||
{
|
||||
m_width = w;
|
||||
|
|
@ -38,7 +38,7 @@ Image::Image (unsigned int w, unsigned int h, lay::color_t *data)
|
|||
m_data.reset (new ImageData (data, w * h));
|
||||
}
|
||||
|
||||
Image::Image (unsigned int w, unsigned int h, const lay::color_t *data, unsigned int stride)
|
||||
PixelBuffer::PixelBuffer (unsigned int w, unsigned int h, const lay::color_t *data, unsigned int stride)
|
||||
: m_data ()
|
||||
{
|
||||
m_width = w;
|
||||
|
|
@ -65,30 +65,30 @@ Image::Image (unsigned int w, unsigned int h, const lay::color_t *data, unsigned
|
|||
m_data.reset (new ImageData (new_data, w * h));
|
||||
}
|
||||
|
||||
Image::Image ()
|
||||
PixelBuffer::PixelBuffer ()
|
||||
{
|
||||
m_width = 0;
|
||||
m_height = 0;
|
||||
m_transparent = false;
|
||||
}
|
||||
|
||||
Image::Image (const Image &other)
|
||||
PixelBuffer::PixelBuffer (const PixelBuffer &other)
|
||||
{
|
||||
operator= (other);
|
||||
}
|
||||
|
||||
Image::Image (Image &&other)
|
||||
PixelBuffer::PixelBuffer (PixelBuffer &&other)
|
||||
{
|
||||
swap (other);
|
||||
}
|
||||
|
||||
Image::~Image ()
|
||||
PixelBuffer::~PixelBuffer ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
Image &
|
||||
Image::operator= (const Image &other)
|
||||
PixelBuffer &
|
||||
PixelBuffer::operator= (const PixelBuffer &other)
|
||||
{
|
||||
if (this != &other) {
|
||||
m_width = other.m_width;
|
||||
|
|
@ -99,8 +99,8 @@ Image::operator= (const Image &other)
|
|||
return *this;
|
||||
}
|
||||
|
||||
Image &
|
||||
Image::operator= (Image &&other)
|
||||
PixelBuffer &
|
||||
PixelBuffer::operator= (PixelBuffer &&other)
|
||||
{
|
||||
if (this != &other) {
|
||||
swap (other);
|
||||
|
|
@ -109,13 +109,13 @@ Image::operator= (Image &&other)
|
|||
}
|
||||
|
||||
void
|
||||
Image::set_transparent (bool f)
|
||||
PixelBuffer::set_transparent (bool f)
|
||||
{
|
||||
m_transparent = f;
|
||||
}
|
||||
|
||||
void
|
||||
Image::swap (Image &other)
|
||||
PixelBuffer::swap (PixelBuffer &other)
|
||||
{
|
||||
if (this == &other) {
|
||||
return;
|
||||
|
|
@ -128,7 +128,7 @@ Image::swap (Image &other)
|
|||
}
|
||||
|
||||
void
|
||||
Image::fill (lay::color_t c)
|
||||
PixelBuffer::fill (lay::color_t c)
|
||||
{
|
||||
color_t *d = data ();
|
||||
for (unsigned int i = 0; i < m_height; ++i) {
|
||||
|
|
@ -139,41 +139,41 @@ Image::fill (lay::color_t c)
|
|||
}
|
||||
|
||||
color_t *
|
||||
Image::scan_line (unsigned int n)
|
||||
PixelBuffer::scan_line (unsigned int n)
|
||||
{
|
||||
tl_assert (n < m_height);
|
||||
return m_data->data () + n * m_width;
|
||||
}
|
||||
|
||||
const color_t *
|
||||
Image::scan_line (unsigned int n) const
|
||||
PixelBuffer::scan_line (unsigned int n) const
|
||||
{
|
||||
tl_assert (n < m_height);
|
||||
return m_data->data () + n * m_width;
|
||||
}
|
||||
|
||||
color_t *
|
||||
Image::data ()
|
||||
PixelBuffer::data ()
|
||||
{
|
||||
return m_data->data ();
|
||||
}
|
||||
|
||||
const color_t *
|
||||
Image::data () const
|
||||
PixelBuffer::data () const
|
||||
{
|
||||
return m_data->data ();
|
||||
}
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
QImage
|
||||
Image::to_image () const
|
||||
PixelBuffer::to_image () const
|
||||
{
|
||||
return QImage ((const uchar *) data (), m_width, m_height, m_transparent ? QImage::Format_ARGB32 : QImage::Format_RGB32);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
Image::patch (const Image &other)
|
||||
PixelBuffer::patch (const PixelBuffer &other)
|
||||
{
|
||||
tl_assert (width () == other.width ());
|
||||
tl_assert (height () == other.height ());
|
||||
|
|
@ -192,13 +192,13 @@ Image::patch (const Image &other)
|
|||
}
|
||||
}
|
||||
|
||||
Image
|
||||
Image::diff (const Image &other) const
|
||||
PixelBuffer
|
||||
PixelBuffer::diff (const PixelBuffer &other) const
|
||||
{
|
||||
tl_assert (width () == other.width ());
|
||||
tl_assert (height () == other.height ());
|
||||
|
||||
Image res (m_width, m_height);
|
||||
PixelBuffer res (m_width, m_height);
|
||||
res.set_transparent (true);
|
||||
|
||||
const color_t *d2 = other.data ();
|
||||
|
|
@ -221,7 +221,7 @@ Image::diff (const Image &other) const
|
|||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
// MonoImage implementation
|
||||
// BitmapBuffer implementation
|
||||
|
||||
static unsigned int
|
||||
stride_from_width (unsigned int w)
|
||||
|
|
@ -230,7 +230,7 @@ stride_from_width (unsigned int w)
|
|||
return 4 * ((w + 31) / 32);
|
||||
}
|
||||
|
||||
MonoImage::MonoImage (unsigned int w, unsigned int h, uint8_t *data)
|
||||
BitmapBuffer::BitmapBuffer (unsigned int w, unsigned int h, uint8_t *data)
|
||||
{
|
||||
m_width = w;
|
||||
m_height = h;
|
||||
|
|
@ -238,7 +238,7 @@ MonoImage::MonoImage (unsigned int w, unsigned int h, uint8_t *data)
|
|||
m_data.reset (new MonoImageData (data, m_stride * h));
|
||||
}
|
||||
|
||||
MonoImage::MonoImage (unsigned int w, unsigned int h, const uint8_t *data, unsigned int stride)
|
||||
BitmapBuffer::BitmapBuffer (unsigned int w, unsigned int h, const uint8_t *data, unsigned int stride)
|
||||
{
|
||||
m_width = w;
|
||||
m_height = h;
|
||||
|
|
@ -261,30 +261,30 @@ MonoImage::MonoImage (unsigned int w, unsigned int h, const uint8_t *data, unsig
|
|||
m_data.reset (new MonoImageData (new_data, m_stride * h));
|
||||
}
|
||||
|
||||
MonoImage::MonoImage ()
|
||||
BitmapBuffer::BitmapBuffer ()
|
||||
{
|
||||
m_width = 0;
|
||||
m_height = 0;
|
||||
m_stride = 0;
|
||||
}
|
||||
|
||||
MonoImage::MonoImage (const MonoImage &other)
|
||||
BitmapBuffer::BitmapBuffer (const BitmapBuffer &other)
|
||||
{
|
||||
operator= (other);
|
||||
}
|
||||
|
||||
MonoImage::MonoImage (MonoImage &&other)
|
||||
BitmapBuffer::BitmapBuffer (BitmapBuffer &&other)
|
||||
{
|
||||
swap (other);
|
||||
}
|
||||
|
||||
MonoImage::~MonoImage ()
|
||||
BitmapBuffer::~BitmapBuffer ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
MonoImage &
|
||||
MonoImage::operator= (const MonoImage &other)
|
||||
BitmapBuffer &
|
||||
BitmapBuffer::operator= (const BitmapBuffer &other)
|
||||
{
|
||||
if (this != &other) {
|
||||
m_width = other.m_width;
|
||||
|
|
@ -295,8 +295,8 @@ MonoImage::operator= (const MonoImage &other)
|
|||
return *this;
|
||||
}
|
||||
|
||||
MonoImage &
|
||||
MonoImage::operator= (MonoImage &&other)
|
||||
BitmapBuffer &
|
||||
BitmapBuffer::operator= (BitmapBuffer &&other)
|
||||
{
|
||||
if (this != &other) {
|
||||
swap (other);
|
||||
|
|
@ -305,7 +305,7 @@ MonoImage::operator= (MonoImage &&other)
|
|||
}
|
||||
|
||||
void
|
||||
MonoImage::swap (MonoImage &other)
|
||||
BitmapBuffer::swap (BitmapBuffer &other)
|
||||
{
|
||||
if (this == &other) {
|
||||
return;
|
||||
|
|
@ -318,7 +318,7 @@ MonoImage::swap (MonoImage &other)
|
|||
}
|
||||
|
||||
void
|
||||
MonoImage::fill (bool value)
|
||||
BitmapBuffer::fill (bool value)
|
||||
{
|
||||
uint8_t c = value ? 0xff : 0;
|
||||
uint8_t *d = data ();
|
||||
|
|
@ -330,34 +330,34 @@ MonoImage::fill (bool value)
|
|||
}
|
||||
|
||||
uint8_t *
|
||||
MonoImage::scan_line (unsigned int n)
|
||||
BitmapBuffer::scan_line (unsigned int n)
|
||||
{
|
||||
tl_assert (n < m_height);
|
||||
return m_data->data () + n * m_stride;
|
||||
}
|
||||
|
||||
const uint8_t *
|
||||
MonoImage::scan_line (unsigned int n) const
|
||||
BitmapBuffer::scan_line (unsigned int n) const
|
||||
{
|
||||
tl_assert (n < m_height);
|
||||
return m_data->data () + n * m_stride;
|
||||
}
|
||||
|
||||
uint8_t *
|
||||
MonoImage::data ()
|
||||
BitmapBuffer::data ()
|
||||
{
|
||||
return m_data->data ();
|
||||
}
|
||||
|
||||
const uint8_t *
|
||||
MonoImage::data () const
|
||||
BitmapBuffer::data () const
|
||||
{
|
||||
return m_data->data ();
|
||||
}
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
QImage
|
||||
MonoImage::to_image () const
|
||||
BitmapBuffer::to_image () const
|
||||
{
|
||||
QImage img = QImage ((const uchar *) data (), m_width, m_height, QImage::Format_MonoLSB);
|
||||
img.setColor (0, 0xff000000);
|
||||
|
|
@ -21,8 +21,8 @@
|
|||
*/
|
||||
|
||||
|
||||
#ifndef HDR_layImage
|
||||
#define HDR_layImage
|
||||
#ifndef HDR_layPixelBuffer
|
||||
#define HDR_layPixelBuffer
|
||||
|
||||
#include "laybasicCommon.h"
|
||||
#include "layColor.h"
|
||||
|
|
@ -45,7 +45,7 @@ namespace lay
|
|||
* It provides 32bit RGBA pixels with the format used by lay::Color.
|
||||
*/
|
||||
|
||||
class LAYBASIC_PUBLIC Image
|
||||
class LAYBASIC_PUBLIC PixelBuffer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
|
@ -56,7 +56,7 @@ public:
|
|||
*
|
||||
* The size of the data block needs to be w*h elements.
|
||||
*/
|
||||
Image (unsigned int w, unsigned int h, lay::color_t *data);
|
||||
PixelBuffer (unsigned int w, unsigned int h, lay::color_t *data);
|
||||
|
||||
/**
|
||||
* @brief Creates an image with the given height and width
|
||||
|
|
@ -66,37 +66,37 @@ public:
|
|||
* "stride" specifies the stride (distance between two rows of data).
|
||||
* The size of the data block needs to be stride*h elements or w*h if stride is not given.
|
||||
*/
|
||||
Image (unsigned int w, unsigned int h, const lay::color_t *data = 0, unsigned int stride = 0);
|
||||
PixelBuffer (unsigned int w, unsigned int h, const lay::color_t *data = 0, unsigned int stride = 0);
|
||||
|
||||
/**
|
||||
* @brief Default constructor
|
||||
*/
|
||||
Image ();
|
||||
PixelBuffer ();
|
||||
|
||||
/**
|
||||
* @brief Copy constructor
|
||||
*/
|
||||
Image (const Image &other);
|
||||
PixelBuffer (const PixelBuffer &other);
|
||||
|
||||
/**
|
||||
* @brief Move constructor
|
||||
*/
|
||||
Image (Image &&other);
|
||||
PixelBuffer (PixelBuffer &&other);
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
~Image ();
|
||||
~PixelBuffer ();
|
||||
|
||||
/**
|
||||
* @brief Assignment
|
||||
*/
|
||||
Image &operator= (const Image &other);
|
||||
PixelBuffer &operator= (const PixelBuffer &other);
|
||||
|
||||
/**
|
||||
* @brief Move constructor
|
||||
*/
|
||||
Image &operator= (Image &&other);
|
||||
PixelBuffer &operator= (PixelBuffer &&other);
|
||||
|
||||
/**
|
||||
* @brief Sets a value indicating whether an alpha channel is present
|
||||
|
|
@ -114,7 +114,7 @@ public:
|
|||
/**
|
||||
* @brief Swaps this image with another one
|
||||
*/
|
||||
void swap (Image &other);
|
||||
void swap (PixelBuffer &other);
|
||||
|
||||
/**
|
||||
* @brief Gets the images width
|
||||
|
|
@ -178,7 +178,7 @@ public:
|
|||
* This feature does not implement real alpha blending. Instead all
|
||||
* pixels with an alpha value >= 128 from the other image are patched into this image.
|
||||
*/
|
||||
void patch (const Image &other);
|
||||
void patch (const PixelBuffer &other);
|
||||
|
||||
/**
|
||||
* @brief Generates the image difference
|
||||
|
|
@ -190,7 +190,7 @@ public:
|
|||
*
|
||||
* alpha values from this and other are ignored.
|
||||
*/
|
||||
Image diff (const Image &other) const;
|
||||
PixelBuffer diff (const PixelBuffer &other) const;
|
||||
|
||||
private:
|
||||
class ImageData
|
||||
|
|
@ -243,7 +243,7 @@ private:
|
|||
* This class substitutes QImage for monochrome images in Qt-less applications.
|
||||
*/
|
||||
|
||||
class LAYBASIC_PUBLIC MonoImage
|
||||
class LAYBASIC_PUBLIC BitmapBuffer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
|
@ -254,7 +254,7 @@ public:
|
|||
*
|
||||
* Lines are byte-aligned.
|
||||
*/
|
||||
MonoImage (unsigned int w, unsigned int h, uint8_t *data);
|
||||
BitmapBuffer (unsigned int w, unsigned int h, uint8_t *data);
|
||||
|
||||
/**
|
||||
* @brief Creates an image with the given height and width
|
||||
|
|
@ -264,42 +264,42 @@ public:
|
|||
* "stride" specifies the stride (distance in bytes between two rows of data).
|
||||
* The size of the data block needs to be stride*h elements or bytes(w)*h if stride is not given.
|
||||
*/
|
||||
MonoImage (unsigned int w, unsigned int h, const uint8_t *data = 0, unsigned int stride = 0);
|
||||
BitmapBuffer (unsigned int w, unsigned int h, const uint8_t *data = 0, unsigned int stride = 0);
|
||||
|
||||
/**
|
||||
* @brief Default constructor
|
||||
*/
|
||||
MonoImage ();
|
||||
BitmapBuffer ();
|
||||
|
||||
/**
|
||||
* @brief Copy constructor
|
||||
*/
|
||||
MonoImage (const MonoImage &other);
|
||||
BitmapBuffer (const BitmapBuffer &other);
|
||||
|
||||
/**
|
||||
* @brief Move constructor
|
||||
*/
|
||||
MonoImage (MonoImage &&other);
|
||||
BitmapBuffer (BitmapBuffer &&other);
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
~MonoImage ();
|
||||
~BitmapBuffer ();
|
||||
|
||||
/**
|
||||
* @brief Assignment
|
||||
*/
|
||||
MonoImage &operator= (const MonoImage &other);
|
||||
BitmapBuffer &operator= (const BitmapBuffer &other);
|
||||
|
||||
/**
|
||||
* @brief Move constructor
|
||||
*/
|
||||
MonoImage &operator= (MonoImage &&other);
|
||||
BitmapBuffer &operator= (BitmapBuffer &&other);
|
||||
|
||||
/**
|
||||
* @brief Swaps this image with another one
|
||||
*/
|
||||
void swap (MonoImage &other);
|
||||
void swap (BitmapBuffer &other);
|
||||
|
||||
/**
|
||||
* @brief Gets the images width
|
||||
|
|
@ -118,7 +118,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY
|
|||
layGenericSyntaxHighlighter.cc \
|
||||
layGridNetConfigPage.cc \
|
||||
layHierarchyControlPanel.cc \
|
||||
layImage.cc \
|
||||
layIndexedNetlistModel.cc \
|
||||
layItemDelegates.cc \
|
||||
layLayerControlPanel.cc \
|
||||
|
|
@ -139,6 +138,7 @@ DEFINES += MAKE_LAYBASIC_LIBRARY
|
|||
layNetlistBrowserPage.cc \
|
||||
layNetlistBrowserTreeModel.cc \
|
||||
layNetlistCrossReferenceModel.cc \
|
||||
layPixelBuffer.cc \
|
||||
layPluginConfigPage.cc \
|
||||
layProperties.cc \
|
||||
layPropertiesDialog.cc \
|
||||
|
|
@ -192,7 +192,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY
|
|||
layGenericSyntaxHighlighter.h \
|
||||
layGridNetConfigPage.h \
|
||||
layHierarchyControlPanel.h \
|
||||
layImage.h \
|
||||
layIndexedNetlistModel.h \
|
||||
layItemDelegates.h \
|
||||
layLayerControlPanel.h \
|
||||
|
|
@ -213,6 +212,7 @@ DEFINES += MAKE_LAYBASIC_LIBRARY
|
|||
layNetlistBrowserPage.h \
|
||||
layNetlistBrowserTreeModel.h \
|
||||
layNetlistCrossReferenceModel.h \
|
||||
layPixelBuffer.h \
|
||||
layPluginConfigPage.h \
|
||||
layProperties.h \
|
||||
layPropertiesDialog.h \
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
*/
|
||||
|
||||
#include "layImage.h"
|
||||
#include "layPixelBuffer.h"
|
||||
|
||||
#include "tlUnitTest.h"
|
||||
#include "tlTimer.h"
|
||||
|
|
@ -69,7 +69,7 @@ static bool compare_images_mono (const QImage &qimg, const std::string &au)
|
|||
}
|
||||
}
|
||||
|
||||
static bool compare_images (const lay::Image &img, const lay::Image &img2)
|
||||
static bool compare_images (const lay::PixelBuffer &img, const lay::PixelBuffer &img2)
|
||||
{
|
||||
if (img2.width () == img.width () && img2.height () == img.height ()) {
|
||||
for (unsigned int j = 0; j < img.height (); ++j) {
|
||||
|
|
@ -85,7 +85,7 @@ static bool compare_images (const lay::Image &img, const lay::Image &img2)
|
|||
}
|
||||
}
|
||||
|
||||
static bool compare_images (const lay::MonoImage &img, const lay::MonoImage &img2)
|
||||
static bool compare_images (const lay::BitmapBuffer &img, const lay::BitmapBuffer &img2)
|
||||
{
|
||||
if (img2.width () == img.width () && img2.height () == img.height ()) {
|
||||
for (unsigned int j = 0; j < img.height (); ++j) {
|
||||
|
|
@ -105,7 +105,7 @@ static bool compare_images (const lay::MonoImage &img, const lay::MonoImage &img
|
|||
|
||||
TEST(1)
|
||||
{
|
||||
lay::Image img (15, 25);
|
||||
lay::PixelBuffer img (15, 25);
|
||||
EXPECT_EQ (img.width (), 15);
|
||||
EXPECT_EQ (img.height (), 25);
|
||||
EXPECT_EQ (img.stride (), 15 * sizeof (lay::color_t));
|
||||
|
|
@ -117,7 +117,7 @@ TEST(1)
|
|||
img.fill (0x112233);
|
||||
EXPECT_EQ (img.scan_line (5)[10], 0x112233);
|
||||
|
||||
lay::Image img2;
|
||||
lay::PixelBuffer img2;
|
||||
EXPECT_EQ (img2.transparent (), false);
|
||||
img2 = img;
|
||||
EXPECT_EQ (img2.transparent (), true);
|
||||
|
|
@ -142,7 +142,7 @@ TEST(1)
|
|||
EXPECT_EQ (img.scan_line (5)[10], 0x332211);
|
||||
EXPECT_EQ (img2.scan_line (5)[10], 0x332211);
|
||||
|
||||
img2 = lay::Image (10, 16);
|
||||
img2 = lay::PixelBuffer (10, 16);
|
||||
EXPECT_EQ (img.width (), 15);
|
||||
EXPECT_EQ (img.height (), 25);
|
||||
EXPECT_EQ (img2.width (), 10);
|
||||
|
|
@ -159,7 +159,7 @@ TEST(1)
|
|||
EXPECT_EQ (img.height (), 16);
|
||||
EXPECT_EQ (img.scan_line (5)[8], 0x010203);
|
||||
|
||||
lay::Image img3 (img);
|
||||
lay::PixelBuffer img3 (img);
|
||||
EXPECT_EQ (compare_images (img, img3), true);
|
||||
EXPECT_EQ (img3.width (), 10);
|
||||
EXPECT_EQ (img3.height (), 16);
|
||||
|
|
@ -174,25 +174,25 @@ TEST(1)
|
|||
EXPECT_EQ (img.height (), 16);
|
||||
EXPECT_EQ (img.scan_line (5)[8], 0x102030);
|
||||
|
||||
lay::Image img4 (std::move (img));
|
||||
lay::PixelBuffer img4 (std::move (img));
|
||||
EXPECT_EQ (img4.width (), 10);
|
||||
EXPECT_EQ (img4.height (), 16);
|
||||
EXPECT_EQ (img4.scan_line (5)[8], 0x102030);
|
||||
|
||||
// other constructors
|
||||
EXPECT_EQ (compare_images (lay::Image (img4.width (), img4.height (), (const lay::color_t *) img4.data ()), img4), true);
|
||||
EXPECT_EQ (compare_images (lay::Image (img4.width (), img4.height (), (const lay::color_t *) img4.data (), img4.stride ()), img4), true);
|
||||
EXPECT_EQ (compare_images (lay::PixelBuffer (img4.width (), img4.height (), (const lay::color_t *) img4.data ()), img4), true);
|
||||
EXPECT_EQ (compare_images (lay::PixelBuffer (img4.width (), img4.height (), (const lay::color_t *) img4.data (), img4.stride ()), img4), true);
|
||||
|
||||
lay::color_t *dnew = new lay::color_t [ img4.width () * img4.height () * sizeof (lay::color_t) ];
|
||||
memcpy (dnew, (const lay::color_t *) img4.data (), img4.width () * img4.height () * sizeof (lay::color_t));
|
||||
EXPECT_EQ (compare_images (lay::Image (img4.width (), img4.height (), dnew), img4), true);
|
||||
EXPECT_EQ (compare_images (lay::PixelBuffer (img4.width (), img4.height (), dnew), img4), true);
|
||||
}
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
|
||||
TEST(2)
|
||||
{
|
||||
lay::Image img (227, 231);
|
||||
lay::PixelBuffer img (227, 231);
|
||||
|
||||
for (unsigned int i = 0; i < img.width (); ++i) {
|
||||
for (unsigned int j = 0; j < img.height (); ++j) {
|
||||
|
|
@ -213,10 +213,10 @@ TEST(2)
|
|||
|
||||
EXPECT_EQ (compare_images (qimg, au), true);
|
||||
|
||||
lay::Image img_saved (img);
|
||||
lay::PixelBuffer img_saved (img);
|
||||
img.scan_line (52) [42] = 0xff000000;
|
||||
|
||||
lay::Image diff = img.diff (img_saved);
|
||||
lay::PixelBuffer diff = img.diff (img_saved);
|
||||
EXPECT_EQ (diff.transparent (), true);
|
||||
EXPECT_EQ (diff.to_image ().format () == QImage::Format_ARGB32, true);
|
||||
EXPECT_EQ (compare_images (img.to_image (), au), false);
|
||||
|
|
@ -246,11 +246,11 @@ TEST(3)
|
|||
{
|
||||
tl::SelfTimer timer ("Run time - lay::Image copy, no write (should be very fast)");
|
||||
|
||||
lay::Image img (1000, 1000);
|
||||
lay::PixelBuffer img (1000, 1000);
|
||||
img.fill (0x112233);
|
||||
|
||||
for (unsigned int i = 0; i < 5000; ++i) {
|
||||
lay::Image img2 (img);
|
||||
lay::PixelBuffer img2 (img);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -258,7 +258,7 @@ TEST(3)
|
|||
{
|
||||
tl::SelfTimer timer ("Run time - QImage copy, no write (should be very fast)");
|
||||
|
||||
lay::Image img (1000, 1000);
|
||||
lay::PixelBuffer img (1000, 1000);
|
||||
img.fill (0x112233);
|
||||
QImage qimg (img.to_image ());
|
||||
|
||||
|
|
@ -271,11 +271,11 @@ TEST(3)
|
|||
{
|
||||
tl::SelfTimer timer ("Run time - lay::Image copy on write");
|
||||
|
||||
lay::Image img (1000, 1000);
|
||||
lay::PixelBuffer img (1000, 1000);
|
||||
img.fill (0x112233);
|
||||
|
||||
for (unsigned int i = 0; i < 5000; ++i) {
|
||||
lay::Image img2 (img);
|
||||
lay::PixelBuffer img2 (img);
|
||||
img2.scan_line (100) [7] = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -284,7 +284,7 @@ TEST(3)
|
|||
{
|
||||
tl::SelfTimer timer ("Run time - QImage copy on write (should not be much less than lay::Image copy on write)");
|
||||
|
||||
lay::Image img (1000, 1000);
|
||||
lay::PixelBuffer img (1000, 1000);
|
||||
img.fill (0x112233);
|
||||
QImage qimg (img.to_image ());
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ TEST(3)
|
|||
{
|
||||
tl::SelfTimer timer ("Run time - direct QImage paint");
|
||||
|
||||
lay::Image img (1000, 1000);
|
||||
lay::PixelBuffer img (1000, 1000);
|
||||
img.fill (0x112233);
|
||||
QImage qimg (img.to_image ());
|
||||
QImage qrec (img.to_image ());
|
||||
|
|
@ -312,7 +312,7 @@ TEST(3)
|
|||
{
|
||||
tl::SelfTimer timer ("Run time - lay::Image paint (should not be much more than direct QImage paint)");
|
||||
|
||||
lay::Image img (1000, 1000);
|
||||
lay::PixelBuffer img (1000, 1000);
|
||||
img.fill (0x112233);
|
||||
QImage qrec (img.to_image ());
|
||||
qrec.fill (0);
|
||||
|
|
@ -330,7 +330,7 @@ TEST(3)
|
|||
|
||||
TEST(11)
|
||||
{
|
||||
lay::MonoImage img (15, 25);
|
||||
lay::BitmapBuffer img (15, 25);
|
||||
EXPECT_EQ (img.width (), 15);
|
||||
EXPECT_EQ (img.height (), 25);
|
||||
EXPECT_EQ (img.stride (), 4);
|
||||
|
|
@ -338,7 +338,7 @@ TEST(11)
|
|||
img.fill (true);
|
||||
EXPECT_EQ (img.scan_line (5)[1], 0xff);
|
||||
|
||||
lay::MonoImage img2;
|
||||
lay::BitmapBuffer img2;
|
||||
img2 = img;
|
||||
EXPECT_EQ (img2.width (), 15);
|
||||
EXPECT_EQ (img2.height (), 25);
|
||||
|
|
@ -359,7 +359,7 @@ TEST(11)
|
|||
EXPECT_EQ (img.scan_line (5)[1], 0);
|
||||
EXPECT_EQ (img2.scan_line (5)[1], 0);
|
||||
|
||||
img2 = lay::MonoImage (10, 16);
|
||||
img2 = lay::BitmapBuffer (10, 16);
|
||||
EXPECT_EQ (img.width (), 15);
|
||||
EXPECT_EQ (img.height (), 25);
|
||||
EXPECT_EQ (img2.width (), 10);
|
||||
|
|
@ -376,7 +376,7 @@ TEST(11)
|
|||
EXPECT_EQ (img.height (), 16);
|
||||
EXPECT_EQ (img.scan_line (5)[0], 0xff);
|
||||
|
||||
lay::MonoImage img3 (img);
|
||||
lay::BitmapBuffer img3 (img);
|
||||
EXPECT_EQ (compare_images (img, img3), true);
|
||||
EXPECT_EQ (img3.width (), 10);
|
||||
EXPECT_EQ (img3.height (), 16);
|
||||
|
|
@ -391,25 +391,25 @@ TEST(11)
|
|||
EXPECT_EQ (img.height (), 16);
|
||||
EXPECT_EQ (img.scan_line (5)[1], 0);
|
||||
|
||||
lay::MonoImage img4 (std::move (img));
|
||||
lay::BitmapBuffer img4 (std::move (img));
|
||||
EXPECT_EQ (img4.width (), 10);
|
||||
EXPECT_EQ (img4.height (), 16);
|
||||
EXPECT_EQ (img4.scan_line (5)[1], 0);
|
||||
|
||||
// other constructors
|
||||
EXPECT_EQ (compare_images (lay::MonoImage (img4.width (), img4.height (), (const uint8_t *) img4.data ()), img4), true);
|
||||
EXPECT_EQ (compare_images (lay::MonoImage (img4.width (), img4.height (), (const uint8_t *) img4.data (), img4.stride ()), img4), true);
|
||||
EXPECT_EQ (compare_images (lay::BitmapBuffer (img4.width (), img4.height (), (const uint8_t *) img4.data ()), img4), true);
|
||||
EXPECT_EQ (compare_images (lay::BitmapBuffer (img4.width (), img4.height (), (const uint8_t *) img4.data (), img4.stride ()), img4), true);
|
||||
|
||||
uint8_t *dnew = new uint8_t [ img4.width () * img4.height () * sizeof (uint8_t) ];
|
||||
memcpy (dnew, (const uint8_t *) img4.data (), img4.stride () * img4.height ());
|
||||
EXPECT_EQ (compare_images (lay::MonoImage (img4.width (), img4.height (), dnew), img4), true);
|
||||
EXPECT_EQ (compare_images (lay::BitmapBuffer (img4.width (), img4.height (), dnew), img4), true);
|
||||
}
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
|
||||
TEST(12)
|
||||
{
|
||||
lay::MonoImage img (227, 231);
|
||||
lay::BitmapBuffer img (227, 231);
|
||||
|
||||
for (unsigned int i = 0; i < img.stride (); ++i) {
|
||||
for (unsigned int j = 0; j < img.height (); ++j) {
|
||||
|
|
@ -10,10 +10,10 @@ SOURCES = \
|
|||
layAnnotationShapes.cc \
|
||||
layBitmap.cc \
|
||||
layBitmapsToImage.cc \
|
||||
layImageTests.cc \
|
||||
layColorTests.cc \
|
||||
layLayerProperties.cc \
|
||||
layParsedLayerSource.cc \
|
||||
layPixelBufferTests.cc \
|
||||
layRenderer.cc \
|
||||
layNetlistBrowserModelTests.cc \
|
||||
layNetlistBrowserTreeModelTests.cc \
|
||||
|
|
|
|||
Loading…
Reference in New Issue