mirror of https://github.com/KLayout/klayout.git
Refactoring: lay::PixelBuffer, BitmapBuffer -> tl, added image functions to RdbItem in GSI
This commit is contained in:
parent
62bbef53ac
commit
b95027a21b
|
|
@ -47,7 +47,9 @@ HEADERS = \
|
||||||
|
|
||||||
# Note: unlike other modules, the tl declarations have to go here
|
# Note: unlike other modules, the tl declarations have to go here
|
||||||
# since gsi is dependent on tl
|
# since gsi is dependent on tl
|
||||||
SOURCES += gsiDeclTl.cc
|
SOURCES += \
|
||||||
|
gsiDeclTl.cc \
|
||||||
|
gsiDeclTlPixelBuffer.cc
|
||||||
|
|
||||||
INCLUDEPATH += $$TL_INC
|
INCLUDEPATH += $$TL_INC
|
||||||
DEPENDPATH += $$TL_INC
|
DEPENDPATH += $$TL_INC
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gsiDecl.h"
|
#include "gsiDecl.h"
|
||||||
#include "layPixelBuffer.h"
|
#include "tlPixelBuffer.h"
|
||||||
|
|
||||||
#if defined(HAVE_QT)
|
#if defined(HAVE_QT)
|
||||||
# include <QBuffer>
|
# include <QBuffer>
|
||||||
|
|
@ -32,21 +32,21 @@ namespace gsi
|
||||||
{
|
{
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
// lay::BitmapBuffer
|
// tl::BitmapBuffer
|
||||||
|
|
||||||
static lay::PixelBuffer *create_pixel_buffer (unsigned int w, unsigned int h)
|
static tl::PixelBuffer *create_pixel_buffer (unsigned int w, unsigned int h)
|
||||||
{
|
{
|
||||||
return new lay::PixelBuffer (w, h);
|
return new tl::PixelBuffer (w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
||||||
static void fill_with_qcolor (lay::PixelBuffer *pb, QColor c)
|
static void fill_with_qcolor (tl::PixelBuffer *pb, QColor c)
|
||||||
{
|
{
|
||||||
pb->fill (c.rgb ());
|
pb->fill (c.rgb ());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tl::color_t get_pixel_from_pixel_buffer (const lay::PixelBuffer *pb, unsigned int x, unsigned int y)
|
tl::color_t get_pixel_from_pixel_buffer (const tl::PixelBuffer *pb, unsigned int x, unsigned int y)
|
||||||
{
|
{
|
||||||
if (x < pb->width () && y < pb->height ()) {
|
if (x < pb->width () && y < pb->height ()) {
|
||||||
return pb->scan_line (y)[x];
|
return pb->scan_line (y)[x];
|
||||||
|
|
@ -55,7 +55,7 @@ tl::color_t get_pixel_from_pixel_buffer (const lay::PixelBuffer *pb, unsigned in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_pixel_in_pixel_buffer (lay::PixelBuffer *pb, unsigned int x, unsigned int y, tl::color_t c)
|
void set_pixel_in_pixel_buffer (tl::PixelBuffer *pb, unsigned int x, unsigned int y, tl::color_t c)
|
||||||
{
|
{
|
||||||
if (! pb->transparent ()) {
|
if (! pb->transparent ()) {
|
||||||
c |= 0xff000000; // ensures that alpha is set properly even if not required
|
c |= 0xff000000; // ensures that alpha is set properly even if not required
|
||||||
|
|
@ -65,41 +65,41 @@ void set_pixel_in_pixel_buffer (lay::PixelBuffer *pb, unsigned int x, unsigned i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static lay::PixelBuffer read_pixel_buffer (const std::string &file)
|
static tl::PixelBuffer read_pixel_buffer (const std::string &file)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_PNG)
|
#if defined(HAVE_PNG)
|
||||||
tl::InputStream stream (file);
|
tl::InputStream stream (file);
|
||||||
return lay::PixelBuffer::read_png (stream);
|
return tl::PixelBuffer::read_png (stream);
|
||||||
#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
||||||
// QImage is fallback
|
// QImage is fallback
|
||||||
QImage img;
|
QImage img;
|
||||||
img.load (tl::to_qstring (file), "PNG");
|
img.load (tl::to_qstring (file), "PNG");
|
||||||
return lay::PixelBuffer::from_image (img);
|
return tl::PixelBuffer::from_image (img);
|
||||||
#else
|
#else
|
||||||
throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for PixelBuffer")));
|
throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for PixelBuffer")));
|
||||||
return lay::PixelBuffer ();
|
return tl::PixelBuffer ();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: there should be some more efficient version of byte strings which avoid copies
|
// TODO: there should be some more efficient version of byte strings which avoid copies
|
||||||
static lay::PixelBuffer pixel_buffer_from_png (const std::vector<char> &data)
|
static tl::PixelBuffer pixel_buffer_from_png (const std::vector<char> &data)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_PNG)
|
#if defined(HAVE_PNG)
|
||||||
tl::InputMemoryStream data_stream (data.begin ().operator-> (), data.size ());
|
tl::InputMemoryStream data_stream (data.begin ().operator-> (), data.size ());
|
||||||
tl::InputStream stream (data_stream);
|
tl::InputStream stream (data_stream);
|
||||||
return lay::PixelBuffer::read_png (stream);
|
return tl::PixelBuffer::read_png (stream);
|
||||||
#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
||||||
// QImage is fallback
|
// QImage is fallback
|
||||||
tl_assert (data.size () < std::numeric_limits<int>::max ());
|
tl_assert (data.size () < std::numeric_limits<int>::max ());
|
||||||
QImage img = QImage::fromData ((const uchar *) data.begin ().operator-> (), int (data.size ()));
|
QImage img = QImage::fromData ((const uchar *) data.begin ().operator-> (), int (data.size ()));
|
||||||
return lay::PixelBuffer::from_image (img);
|
return tl::PixelBuffer::from_image (img);
|
||||||
#else
|
#else
|
||||||
throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for PixelBuffer")));
|
throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for PixelBuffer")));
|
||||||
return lay::PixelBuffer ();
|
return tl::PixelBuffer ();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_pixel_buffer (const lay::PixelBuffer *pb, const std::string &file)
|
static void write_pixel_buffer (const tl::PixelBuffer *pb, const std::string &file)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_PNG)
|
#if defined(HAVE_PNG)
|
||||||
tl::OutputStream stream (file);
|
tl::OutputStream stream (file);
|
||||||
|
|
@ -114,7 +114,7 @@ static void write_pixel_buffer (const lay::PixelBuffer *pb, const std::string &f
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: there should be some more efficient version of byte strings which avoid copies
|
// TODO: there should be some more efficient version of byte strings which avoid copies
|
||||||
static std::vector<char> pixel_buffer_to_png (const lay::PixelBuffer *pb)
|
static std::vector<char> pixel_buffer_to_png (const tl::PixelBuffer *pb)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_PNG)
|
#if defined(HAVE_PNG)
|
||||||
tl::OutputMemoryStream data_stream;
|
tl::OutputMemoryStream data_stream;
|
||||||
|
|
@ -135,7 +135,7 @@ static std::vector<char> pixel_buffer_to_png (const lay::PixelBuffer *pb)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Class<lay::PixelBuffer> decl_PixelBuffer ("lay", "PixelBuffer",
|
Class<tl::PixelBuffer> decl_PixelBuffer ("lay", "PixelBuffer",
|
||||||
gsi::constructor ("new", &create_pixel_buffer, gsi::arg ("width"), gsi::arg ("height"),
|
gsi::constructor ("new", &create_pixel_buffer, gsi::arg ("width"), gsi::arg ("height"),
|
||||||
"@brief Creates a pixel buffer object\n"
|
"@brief Creates a pixel buffer object\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
|
@ -144,21 +144,21 @@ Class<lay::PixelBuffer> decl_PixelBuffer ("lay", "PixelBuffer",
|
||||||
"\n"
|
"\n"
|
||||||
"The pixels are basically uninitialized. You will need to use \\fill to initialize them to a certain value."
|
"The pixels are basically uninitialized. You will need to use \\fill to initialize them to a certain value."
|
||||||
) +
|
) +
|
||||||
gsi::method ("==", &lay::PixelBuffer::operator==, gsi::arg ("other"),
|
gsi::method ("==", &tl::PixelBuffer::operator==, gsi::arg ("other"),
|
||||||
"@brief Returns a value indicating whether self is identical to the other image\n"
|
"@brief Returns a value indicating whether self is identical to the other image\n"
|
||||||
) +
|
) +
|
||||||
gsi::method ("!=", &lay::PixelBuffer::operator!=, gsi::arg ("other"),
|
gsi::method ("!=", &tl::PixelBuffer::operator!=, gsi::arg ("other"),
|
||||||
"@brief Returns a value indicating whether self is not identical to the other image\n"
|
"@brief Returns a value indicating whether self is not identical to the other image\n"
|
||||||
) +
|
) +
|
||||||
gsi::method ("transparent=", &lay::PixelBuffer::set_transparent, gsi::arg ("t"),
|
gsi::method ("transparent=", &tl::PixelBuffer::set_transparent, gsi::arg ("t"),
|
||||||
"@brief Sets a flag indicating whether the pixel buffer supports an alpha channel\n"
|
"@brief Sets a flag indicating whether the pixel buffer supports an alpha channel\n"
|
||||||
"\n"
|
"\n"
|
||||||
"By default, the pixel buffer does not support an alpha channel.\n"
|
"By default, the pixel buffer does not support an alpha channel.\n"
|
||||||
) +
|
) +
|
||||||
gsi::method ("transparent", &lay::PixelBuffer::transparent,
|
gsi::method ("transparent", &tl::PixelBuffer::transparent,
|
||||||
"@brief Gets a flag indicating whether the pixel buffer supports an alpha channel\n"
|
"@brief Gets a flag indicating whether the pixel buffer supports an alpha channel\n"
|
||||||
) +
|
) +
|
||||||
gsi::method ("fill", &lay::PixelBuffer::fill, gsi::arg ("color"),
|
gsi::method ("fill", &tl::PixelBuffer::fill, gsi::arg ("color"),
|
||||||
"@brief Fills the pixel buffer with the given pixel value\n"
|
"@brief Fills the pixel buffer with the given pixel value\n"
|
||||||
) +
|
) +
|
||||||
#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
||||||
|
|
@ -166,13 +166,13 @@ Class<lay::PixelBuffer> decl_PixelBuffer ("lay", "PixelBuffer",
|
||||||
"@brief Fills the pixel buffer with the given QColor\n"
|
"@brief Fills the pixel buffer with the given QColor\n"
|
||||||
) +
|
) +
|
||||||
#endif
|
#endif
|
||||||
gsi::method ("swap", &lay::PixelBuffer::swap, gsi::arg ("other"),
|
gsi::method ("swap", &tl::PixelBuffer::swap, gsi::arg ("other"),
|
||||||
"@brief Swaps data with another PixelBuffer object\n"
|
"@brief Swaps data with another PixelBuffer object\n"
|
||||||
) +
|
) +
|
||||||
gsi::method ("width", &lay::PixelBuffer::width,
|
gsi::method ("width", &tl::PixelBuffer::width,
|
||||||
"@brief Gets the width of the pixel buffer in pixels\n"
|
"@brief Gets the width of the pixel buffer in pixels\n"
|
||||||
) +
|
) +
|
||||||
gsi::method ("height", &lay::PixelBuffer::height,
|
gsi::method ("height", &tl::PixelBuffer::height,
|
||||||
"@brief Gets the height of the pixel buffer in pixels\n"
|
"@brief Gets the height of the pixel buffer in pixels\n"
|
||||||
) +
|
) +
|
||||||
gsi::method_ext ("set_pixel", &set_pixel_in_pixel_buffer, gsi::arg ("x"), gsi::arg ("y"), gsi::arg ("c"),
|
gsi::method_ext ("set_pixel", &set_pixel_in_pixel_buffer, gsi::arg ("x"), gsi::arg ("y"), gsi::arg ("c"),
|
||||||
|
|
@ -182,10 +182,10 @@ Class<lay::PixelBuffer> decl_PixelBuffer ("lay", "PixelBuffer",
|
||||||
"@brief Gets the value of the pixel at position x, y\n"
|
"@brief Gets the value of the pixel at position x, y\n"
|
||||||
) +
|
) +
|
||||||
#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
||||||
gsi::method ("to_qimage", &lay::PixelBuffer::to_image_copy,
|
gsi::method ("to_qimage", &tl::PixelBuffer::to_image_copy,
|
||||||
"@brief Converts the pixel buffer to a \\QImage object"
|
"@brief Converts the pixel buffer to a \\QImage object"
|
||||||
) +
|
) +
|
||||||
gsi::method ("from_qimage", &lay::PixelBuffer::from_image, gsi::arg ("qimage"),
|
gsi::method ("from_qimage", &tl::PixelBuffer::from_image, gsi::arg ("qimage"),
|
||||||
"@brief Creates a pixel buffer object from a QImage object\n"
|
"@brief Creates a pixel buffer object from a QImage object\n"
|
||||||
) +
|
) +
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -209,14 +209,14 @@ Class<lay::PixelBuffer> decl_PixelBuffer ("lay", "PixelBuffer",
|
||||||
"\n"
|
"\n"
|
||||||
"This method may not be available if PNG support is not compiled into KLayout."
|
"This method may not be available if PNG support is not compiled into KLayout."
|
||||||
) +
|
) +
|
||||||
gsi::method ("patch", &lay::PixelBuffer::patch, gsi::arg ("other"),
|
gsi::method ("patch", &tl::PixelBuffer::patch, gsi::arg ("other"),
|
||||||
"@brief Patches another pixel buffer into this one\n"
|
"@brief Patches another pixel buffer into this one\n"
|
||||||
"\n"
|
"\n"
|
||||||
"This method is the inverse of \\diff - it will patch the difference image created by diff into this "
|
"This method is the inverse of \\diff - it will patch the difference image created by diff into this "
|
||||||
"pixel buffer. Note that this method will not do true alpha blending and requires the other pixel buffer "
|
"pixel buffer. Note that this method will not do true alpha blending and requires the other pixel buffer "
|
||||||
"to have the same format than self. Self will be modified by this operation."
|
"to have the same format than self. Self will be modified by this operation."
|
||||||
) +
|
) +
|
||||||
gsi::method ("diff", &lay::PixelBuffer::diff, gsi::arg ("other"),
|
gsi::method ("diff", &tl::PixelBuffer::diff, gsi::arg ("other"),
|
||||||
"@brief Creates a difference image\n"
|
"@brief Creates a difference image\n"
|
||||||
"\n"
|
"\n"
|
||||||
"This method is provided to support transfer of image differences - i.e. small updates instead of full images. "
|
"This method is provided to support transfer of image differences - i.e. small updates instead of full images. "
|
||||||
|
|
@ -238,14 +238,14 @@ Class<lay::PixelBuffer> decl_PixelBuffer ("lay", "PixelBuffer",
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
// lay::BitmapBuffer
|
// tl::BitmapBuffer
|
||||||
|
|
||||||
static lay::BitmapBuffer *create_bitmap_buffer (unsigned int w, unsigned int h)
|
static tl::BitmapBuffer *create_bitmap_buffer (unsigned int w, unsigned int h)
|
||||||
{
|
{
|
||||||
return new lay::BitmapBuffer (w, h);
|
return new tl::BitmapBuffer (w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_pixel_from_bitmap_buffer (const lay::BitmapBuffer *pb, unsigned int x, unsigned int y)
|
bool get_pixel_from_bitmap_buffer (const tl::BitmapBuffer *pb, unsigned int x, unsigned int y)
|
||||||
{
|
{
|
||||||
if (x < pb->width () && y < pb->height ()) {
|
if (x < pb->width () && y < pb->height ()) {
|
||||||
return (pb->scan_line (y)[x / 8] & (0x01 << (x % 8))) != 0;
|
return (pb->scan_line (y)[x / 8] & (0x01 << (x % 8))) != 0;
|
||||||
|
|
@ -254,7 +254,7 @@ bool get_pixel_from_bitmap_buffer (const lay::BitmapBuffer *pb, unsigned int x,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_pixel_in_bitmap_buffer (lay::BitmapBuffer *pb, unsigned int x, unsigned int y, bool c)
|
void set_pixel_in_bitmap_buffer (tl::BitmapBuffer *pb, unsigned int x, unsigned int y, bool c)
|
||||||
{
|
{
|
||||||
if (x < pb->width () && y < pb->height ()) {
|
if (x < pb->width () && y < pb->height ()) {
|
||||||
if (c) {
|
if (c) {
|
||||||
|
|
@ -265,41 +265,41 @@ void set_pixel_in_bitmap_buffer (lay::BitmapBuffer *pb, unsigned int x, unsigned
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static lay::BitmapBuffer read_bitmap_buffer (const std::string &file)
|
static tl::BitmapBuffer read_bitmap_buffer (const std::string &file)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_PNG)
|
#if defined(HAVE_PNG)
|
||||||
tl::InputStream stream (file);
|
tl::InputStream stream (file);
|
||||||
return lay::BitmapBuffer::read_png (stream);
|
return tl::BitmapBuffer::read_png (stream);
|
||||||
#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
||||||
// QImage is fallback
|
// QImage is fallback
|
||||||
QImage img;
|
QImage img;
|
||||||
img.load (tl::to_qstring (file), "PNG");
|
img.load (tl::to_qstring (file), "PNG");
|
||||||
return lay::BitmapBuffer::from_image (img);
|
return tl::BitmapBuffer::from_image (img);
|
||||||
#else
|
#else
|
||||||
throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for BitmapBuffer")));
|
throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for BitmapBuffer")));
|
||||||
return lay::BitmapBuffer ();
|
return tl::BitmapBuffer ();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: there should be some more efficient version of byte strings which avoid copies
|
// TODO: there should be some more efficient version of byte strings which avoid copies
|
||||||
static lay::BitmapBuffer bitmap_buffer_from_png (const std::vector<char> &data)
|
static tl::BitmapBuffer bitmap_buffer_from_png (const std::vector<char> &data)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_PNG)
|
#if defined(HAVE_PNG)
|
||||||
tl::InputMemoryStream data_stream (data.begin ().operator-> (), data.size ());
|
tl::InputMemoryStream data_stream (data.begin ().operator-> (), data.size ());
|
||||||
tl::InputStream stream (data_stream);
|
tl::InputStream stream (data_stream);
|
||||||
return lay::BitmapBuffer::read_png (stream);
|
return tl::BitmapBuffer::read_png (stream);
|
||||||
#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
||||||
// QImage is fallback
|
// QImage is fallback
|
||||||
tl_assert (data.size () < std::numeric_limits<int>::max ());
|
tl_assert (data.size () < std::numeric_limits<int>::max ());
|
||||||
QImage img = QImage::fromData ((const uchar *) data.begin ().operator-> (), int (data.size ()));
|
QImage img = QImage::fromData ((const uchar *) data.begin ().operator-> (), int (data.size ()));
|
||||||
return lay::BitmapBuffer::from_image (img);
|
return tl::BitmapBuffer::from_image (img);
|
||||||
#else
|
#else
|
||||||
throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for BitmapBuffer")));
|
throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for BitmapBuffer")));
|
||||||
return lay::BitmapBuffer ();
|
return tl::BitmapBuffer ();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_bitmap_buffer (const lay::BitmapBuffer *pb, const std::string &file)
|
static void write_bitmap_buffer (const tl::BitmapBuffer *pb, const std::string &file)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_PNG)
|
#if defined(HAVE_PNG)
|
||||||
tl::OutputStream stream (file);
|
tl::OutputStream stream (file);
|
||||||
|
|
@ -314,7 +314,7 @@ static void write_bitmap_buffer (const lay::BitmapBuffer *pb, const std::string
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: there should be some more efficient version of byte strings which avoid copies
|
// TODO: there should be some more efficient version of byte strings which avoid copies
|
||||||
static std::vector<char> bitmap_buffer_to_png (const lay::BitmapBuffer *pb)
|
static std::vector<char> bitmap_buffer_to_png (const tl::BitmapBuffer *pb)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_PNG)
|
#if defined(HAVE_PNG)
|
||||||
tl::OutputMemoryStream data_stream;
|
tl::OutputMemoryStream data_stream;
|
||||||
|
|
@ -335,7 +335,7 @@ static std::vector<char> bitmap_buffer_to_png (const lay::BitmapBuffer *pb)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Class<lay::BitmapBuffer> decl_BitmapBuffer ("lay", "BitmapBuffer",
|
Class<tl::BitmapBuffer> decl_BitmapBuffer ("lay", "BitmapBuffer",
|
||||||
gsi::constructor ("new", &create_bitmap_buffer, gsi::arg ("width"), gsi::arg ("height"),
|
gsi::constructor ("new", &create_bitmap_buffer, gsi::arg ("width"), gsi::arg ("height"),
|
||||||
"@brief Creates a pixel buffer object\n"
|
"@brief Creates a pixel buffer object\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
|
@ -344,13 +344,13 @@ Class<lay::BitmapBuffer> decl_BitmapBuffer ("lay", "BitmapBuffer",
|
||||||
"\n"
|
"\n"
|
||||||
"The pixels are basically uninitialized. You will need to use \\fill to initialize them to a certain value."
|
"The pixels are basically uninitialized. You will need to use \\fill to initialize them to a certain value."
|
||||||
) +
|
) +
|
||||||
gsi::method ("==", &lay::BitmapBuffer::operator==, gsi::arg ("other"),
|
gsi::method ("==", &tl::BitmapBuffer::operator==, gsi::arg ("other"),
|
||||||
"@brief Returns a value indicating whether self is identical to the other image\n"
|
"@brief Returns a value indicating whether self is identical to the other image\n"
|
||||||
) +
|
) +
|
||||||
gsi::method ("!=", &lay::BitmapBuffer::operator!=, gsi::arg ("other"),
|
gsi::method ("!=", &tl::BitmapBuffer::operator!=, gsi::arg ("other"),
|
||||||
"@brief Returns a value indicating whether self is not identical to the other image\n"
|
"@brief Returns a value indicating whether self is not identical to the other image\n"
|
||||||
) +
|
) +
|
||||||
gsi::method ("fill", &lay::BitmapBuffer::fill, gsi::arg ("color"),
|
gsi::method ("fill", &tl::BitmapBuffer::fill, gsi::arg ("color"),
|
||||||
"@brief Fills the pixel buffer with the given pixel value\n"
|
"@brief Fills the pixel buffer with the given pixel value\n"
|
||||||
) +
|
) +
|
||||||
#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
||||||
|
|
@ -358,13 +358,13 @@ Class<lay::BitmapBuffer> decl_BitmapBuffer ("lay", "BitmapBuffer",
|
||||||
"@brief Fills the pixel buffer with the given QColor\n"
|
"@brief Fills the pixel buffer with the given QColor\n"
|
||||||
) +
|
) +
|
||||||
#endif
|
#endif
|
||||||
gsi::method ("swap", &lay::BitmapBuffer::swap, gsi::arg ("other"),
|
gsi::method ("swap", &tl::BitmapBuffer::swap, gsi::arg ("other"),
|
||||||
"@brief Swaps data with another BitmapBuffer object\n"
|
"@brief Swaps data with another BitmapBuffer object\n"
|
||||||
) +
|
) +
|
||||||
gsi::method ("width", &lay::BitmapBuffer::width,
|
gsi::method ("width", &tl::BitmapBuffer::width,
|
||||||
"@brief Gets the width of the pixel buffer in pixels\n"
|
"@brief Gets the width of the pixel buffer in pixels\n"
|
||||||
) +
|
) +
|
||||||
gsi::method ("height", &lay::BitmapBuffer::height,
|
gsi::method ("height", &tl::BitmapBuffer::height,
|
||||||
"@brief Gets the height of the pixel buffer in pixels\n"
|
"@brief Gets the height of the pixel buffer in pixels\n"
|
||||||
) +
|
) +
|
||||||
gsi::method_ext ("set_pixel", &set_pixel_in_bitmap_buffer, gsi::arg ("x"), gsi::arg ("y"), gsi::arg ("c"),
|
gsi::method_ext ("set_pixel", &set_pixel_in_bitmap_buffer, gsi::arg ("x"), gsi::arg ("y"), gsi::arg ("c"),
|
||||||
|
|
@ -374,10 +374,10 @@ Class<lay::BitmapBuffer> decl_BitmapBuffer ("lay", "BitmapBuffer",
|
||||||
"@brief Gets the value of the pixel at position x, y\n"
|
"@brief Gets the value of the pixel at position x, y\n"
|
||||||
) +
|
) +
|
||||||
#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
||||||
gsi::method ("to_qimage", &lay::BitmapBuffer::to_image_copy,
|
gsi::method ("to_qimage", &tl::BitmapBuffer::to_image_copy,
|
||||||
"@brief Converts the pixel buffer to a \\QImage object"
|
"@brief Converts the pixel buffer to a \\QImage object"
|
||||||
) +
|
) +
|
||||||
gsi::method ("from_qimage", &lay::BitmapBuffer::from_image, gsi::arg ("qimage"),
|
gsi::method ("from_qimage", &tl::BitmapBuffer::from_image, gsi::arg ("qimage"),
|
||||||
"@brief Creates a pixel buffer object from a QImage object\n"
|
"@brief Creates a pixel buffer object from a QImage object\n"
|
||||||
) +
|
) +
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
#include "tlTimer.h"
|
#include "tlTimer.h"
|
||||||
#include "layPlugin.h"
|
#include "layPlugin.h"
|
||||||
#include "layConverters.h"
|
#include "layConverters.h"
|
||||||
#include "layPixelBuffer.h"
|
#include "tlPixelBuffer.h"
|
||||||
#include "dbPolygonTools.h"
|
#include "dbPolygonTools.h"
|
||||||
#include "tlFileUtils.h"
|
#include "tlFileUtils.h"
|
||||||
#include "tlUri.h"
|
#include "tlUri.h"
|
||||||
|
|
@ -1628,11 +1628,11 @@ Object::read_file ()
|
||||||
|
|
||||||
#elif defined(HAVE_PNG)
|
#elif defined(HAVE_PNG)
|
||||||
|
|
||||||
lay::PixelBuffer img;
|
tl::PixelBuffer img;
|
||||||
|
|
||||||
{
|
{
|
||||||
tl::InputStream stream (m_filename);
|
tl::InputStream stream (m_filename);
|
||||||
img = lay::PixelBuffer::read_png (stream);
|
img = tl::PixelBuffer::read_png (stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_color = false;
|
bool is_color = false;
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ private:
|
||||||
// -------------------------------------------------------------
|
// -------------------------------------------------------------
|
||||||
|
|
||||||
static void
|
static void
|
||||||
draw_scanline (unsigned int level, const img::Object &image_object, lay::PixelBuffer &pxbuffer, int y, const db::Matrix3d &t, const db::Matrix3d &it, const db::DPoint &q1, const db::DPoint &q2)
|
draw_scanline (unsigned int level, const img::Object &image_object, tl::PixelBuffer &pxbuffer, int y, const db::Matrix3d &t, const db::Matrix3d &it, const db::DPoint &q1, const db::DPoint &q2)
|
||||||
{
|
{
|
||||||
double source_width = image_object.width ();
|
double source_width = image_object.width ();
|
||||||
double source_height = image_object.height ();
|
double source_height = image_object.height ();
|
||||||
|
|
@ -155,7 +155,7 @@ draw_image (const img::Object &image_object, const lay::Viewport &vp, lay::ViewO
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lay::PixelBuffer &image = *bmp_canvas->bg_image ();
|
tl::PixelBuffer &image = *bmp_canvas->bg_image ();
|
||||||
db::DBox source_image_box (0.0, 0.0, image_object.width (), image_object.height ());
|
db::DBox source_image_box (0.0, 0.0, image_object.width (), image_object.height ());
|
||||||
|
|
||||||
// safety measure to avoid division by zero.
|
// safety measure to avoid division by zero.
|
||||||
|
|
|
||||||
|
|
@ -327,12 +327,12 @@ static void save_as2 (lay::LayoutViewBase *view, unsigned int index, const std::
|
||||||
view->save_as (index, filename, tl::OutputStream::OM_Auto, options, true, 0);
|
view->save_as (index, filename, tl::OutputStream::OM_Auto, options, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static lay::PixelBuffer get_pixels_with_options (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box)
|
static tl::PixelBuffer get_pixels_with_options (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box)
|
||||||
{
|
{
|
||||||
return view->get_pixels_with_options (width, height, linewidth, oversampling, resolution, tl::Color (), tl::Color (), tl::Color (), target_box);
|
return view->get_pixels_with_options (width, height, linewidth, oversampling, resolution, tl::Color (), tl::Color (), tl::Color (), target_box);
|
||||||
}
|
}
|
||||||
|
|
||||||
static lay::BitmapBuffer get_pixels_with_options_mono (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, const db::DBox &target_box)
|
static tl::BitmapBuffer get_pixels_with_options_mono (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, const db::DBox &target_box)
|
||||||
{
|
{
|
||||||
return view->get_pixels_with_options_mono (width, height, linewidth, tl::Color (), tl::Color (), tl::Color (), target_box);
|
return view->get_pixels_with_options_mono (width, height, linewidth, tl::Color (), tl::Color (), tl::Color (), target_box);
|
||||||
}
|
}
|
||||||
|
|
@ -1129,7 +1129,7 @@ LAYBASIC_PUBLIC Class<lay::LayoutViewBase> decl_LayoutViewBase (QT_EXTERNAL_BASE
|
||||||
"This method has been introduced in 0.23.10.\n"
|
"This method has been introduced in 0.23.10.\n"
|
||||||
) +
|
) +
|
||||||
#endif
|
#endif
|
||||||
gsi::method ("get_screenshot_pixels", static_cast<lay::PixelBuffer (lay::LayoutViewBase::*) ()> (&lay::LayoutViewBase::get_screenshot_pb),
|
gsi::method ("get_screenshot_pixels", static_cast<tl::PixelBuffer (lay::LayoutViewBase::*) ()> (&lay::LayoutViewBase::get_screenshot_pb),
|
||||||
"@brief Gets a screenshot as a \\PixelBuffer\n"
|
"@brief Gets a screenshot as a \\PixelBuffer\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Getting the image requires the drawing to be complete. Ideally, synchronous mode is switched on "
|
"Getting the image requires the drawing to be complete. Ideally, synchronous mode is switched on "
|
||||||
|
|
@ -1138,7 +1138,7 @@ LAYBASIC_PUBLIC Class<lay::LayoutViewBase> decl_LayoutViewBase (QT_EXTERNAL_BASE
|
||||||
"\n"
|
"\n"
|
||||||
"This method has been introduced in 0.28.\n"
|
"This method has been introduced in 0.28.\n"
|
||||||
) +
|
) +
|
||||||
gsi::method ("get_pixels", static_cast<lay::PixelBuffer (lay::LayoutViewBase::*) (unsigned int, unsigned int)> (&lay::LayoutViewBase::get_pixels), gsi::arg ("width"), gsi::arg ("height"),
|
gsi::method ("get_pixels", static_cast<tl::PixelBuffer (lay::LayoutViewBase::*) (unsigned int, unsigned int)> (&lay::LayoutViewBase::get_pixels), gsi::arg ("width"), gsi::arg ("height"),
|
||||||
"@brief Gets the layout image as a \\PixelBuffer\n"
|
"@brief Gets the layout image as a \\PixelBuffer\n"
|
||||||
"\n"
|
"\n"
|
||||||
"@param width The width of the image to render in pixel.\n"
|
"@param width The width of the image to render in pixel.\n"
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
#include "layBitmap.h"
|
#include "layBitmap.h"
|
||||||
#include "layDitherPattern.h"
|
#include "layDitherPattern.h"
|
||||||
#include "layLineStyles.h"
|
#include "layLineStyles.h"
|
||||||
#include "layPixelBuffer.h"
|
#include "tlPixelBuffer.h"
|
||||||
#include "tlTimer.h"
|
#include "tlTimer.h"
|
||||||
#include "tlAssert.h"
|
#include "tlAssert.h"
|
||||||
#include "tlThreads.h"
|
#include "tlThreads.h"
|
||||||
|
|
@ -426,7 +426,7 @@ bitmaps_to_image (const std::vector<lay::ViewOp> &view_ops_in,
|
||||||
const std::vector<lay::Bitmap *> &pbitmaps_in,
|
const std::vector<lay::Bitmap *> &pbitmaps_in,
|
||||||
const lay::DitherPattern &dp,
|
const lay::DitherPattern &dp,
|
||||||
const lay::LineStyles &ls,
|
const lay::LineStyles &ls,
|
||||||
PixelBuffer *pimage, unsigned int width, unsigned int height,
|
tl::PixelBuffer *pimage, unsigned int width, unsigned int height,
|
||||||
bool use_bitmap_index,
|
bool use_bitmap_index,
|
||||||
tl::Mutex *mutex)
|
tl::Mutex *mutex)
|
||||||
{
|
{
|
||||||
|
|
@ -666,7 +666,7 @@ bitmaps_to_image (const std::vector<lay::ViewOp> &view_ops_in,
|
||||||
const std::vector<lay::Bitmap *> &pbitmaps_in,
|
const std::vector<lay::Bitmap *> &pbitmaps_in,
|
||||||
const lay::DitherPattern &dp,
|
const lay::DitherPattern &dp,
|
||||||
const lay::LineStyles &ls,
|
const lay::LineStyles &ls,
|
||||||
lay::BitmapBuffer *pimage, unsigned int width, unsigned int height,
|
tl::BitmapBuffer *pimage, unsigned int width, unsigned int height,
|
||||||
bool use_bitmap_index,
|
bool use_bitmap_index,
|
||||||
tl::Mutex *mutex)
|
tl::Mutex *mutex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -29,14 +29,18 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace tl
|
||||||
|
{
|
||||||
|
class PixelBuffer;
|
||||||
|
class BitmapBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
namespace lay
|
namespace lay
|
||||||
{
|
{
|
||||||
|
|
||||||
class DitherPattern;
|
class DitherPattern;
|
||||||
class LineStyles;
|
class LineStyles;
|
||||||
class Bitmap;
|
class Bitmap;
|
||||||
class PixelBuffer;
|
|
||||||
class BitmapBuffer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function converts the given set of bitmaps to a PixelBuffer
|
* @brief This function converts the given set of bitmaps to a PixelBuffer
|
||||||
|
|
@ -58,7 +62,7 @@ bitmaps_to_image (const std::vector <lay::ViewOp> &view_ops,
|
||||||
const std::vector <lay::Bitmap *> &pbitmaps,
|
const std::vector <lay::Bitmap *> &pbitmaps,
|
||||||
const lay::DitherPattern &dp,
|
const lay::DitherPattern &dp,
|
||||||
const lay::LineStyles &ls,
|
const lay::LineStyles &ls,
|
||||||
lay::PixelBuffer *pimage, unsigned int width, unsigned int height,
|
tl::PixelBuffer *pimage, unsigned int width, unsigned int height,
|
||||||
bool use_bitmap_index,
|
bool use_bitmap_index,
|
||||||
tl::Mutex *mutex);
|
tl::Mutex *mutex);
|
||||||
|
|
||||||
|
|
@ -72,12 +76,12 @@ bitmaps_to_image (const std::vector <lay::ViewOp> &view_ops,
|
||||||
const std::vector <lay::Bitmap *> &pbitmaps,
|
const std::vector <lay::Bitmap *> &pbitmaps,
|
||||||
const lay::DitherPattern &dp,
|
const lay::DitherPattern &dp,
|
||||||
const lay::LineStyles &ls,
|
const lay::LineStyles &ls,
|
||||||
lay::BitmapBuffer *pimage, unsigned int width, unsigned int height,
|
tl::BitmapBuffer *pimage, unsigned int width, unsigned int height,
|
||||||
bool use_bitmap_index,
|
bool use_bitmap_index,
|
||||||
tl::Mutex *mutex);
|
tl::Mutex *mutex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Convert a lay::Bitmap to a unsigned char * data field to be passed to lay::BitmapBuffer
|
* @brief Convert a lay::Bitmap to a unsigned char * data field to be passed to tl::BitmapBuffer
|
||||||
*
|
*
|
||||||
* This function converts the bitmap given the view_op into a raw byte data
|
* This function converts the bitmap given the view_op into a raw byte data
|
||||||
* field that can be passed to a QBitmap constructor. The data field is not
|
* field that can be passed to a QBitmap constructor. The data field is not
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ std::string ImageCacheEntry::to_string () const
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
static void
|
static void
|
||||||
blowup (const lay::PixelBuffer &src, lay::PixelBuffer &dest, unsigned int os)
|
blowup (const tl::PixelBuffer &src, tl::PixelBuffer &dest, unsigned int os)
|
||||||
{
|
{
|
||||||
unsigned int ymax = src.height ();
|
unsigned int ymax = src.height ();
|
||||||
unsigned int xmax = src.width ();
|
unsigned int xmax = src.width ();
|
||||||
|
|
@ -152,7 +152,7 @@ blowup (const lay::PixelBuffer &src, lay::PixelBuffer &dest, unsigned int os)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
subsample (const lay::PixelBuffer &src, lay::PixelBuffer &dest, unsigned int os, double g)
|
subsample (const tl::PixelBuffer &src, tl::PixelBuffer &dest, unsigned int os, double g)
|
||||||
{
|
{
|
||||||
// TODO: this is probably not compatible with the endianess of SPARC ..
|
// TODO: this is probably not compatible with the endianess of SPARC ..
|
||||||
|
|
||||||
|
|
@ -448,7 +448,7 @@ LayoutCanvas::prepare_drawing ()
|
||||||
if (mp_image) {
|
if (mp_image) {
|
||||||
delete mp_image;
|
delete mp_image;
|
||||||
}
|
}
|
||||||
mp_image = new lay::PixelBuffer (m_viewport_l.width (), m_viewport_l.height ());
|
mp_image = new tl::PixelBuffer (m_viewport_l.width (), m_viewport_l.height ());
|
||||||
if (mp_image_fg) {
|
if (mp_image_fg) {
|
||||||
delete mp_image_fg;
|
delete mp_image_fg;
|
||||||
mp_image_fg = 0;
|
mp_image_fg = 0;
|
||||||
|
|
@ -589,7 +589,7 @@ LayoutCanvas::paint_event ()
|
||||||
if (mp_image_bg) {
|
if (mp_image_bg) {
|
||||||
delete mp_image_bg;
|
delete mp_image_bg;
|
||||||
}
|
}
|
||||||
mp_image_bg = new lay::PixelBuffer (*mp_image);
|
mp_image_bg = new tl::PixelBuffer (*mp_image);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// else reuse the saved image
|
// else reuse the saved image
|
||||||
|
|
@ -622,18 +622,18 @@ LayoutCanvas::paint_event ()
|
||||||
clear_fg_bitmaps ();
|
clear_fg_bitmaps ();
|
||||||
do_render (m_viewport_l, *this, true);
|
do_render (m_viewport_l, *this, true);
|
||||||
|
|
||||||
mp_image_fg = new lay::PixelBuffer ();
|
mp_image_fg = new tl::PixelBuffer ();
|
||||||
|
|
||||||
if (fg_bitmaps () > 0) {
|
if (fg_bitmaps () > 0) {
|
||||||
|
|
||||||
lay::PixelBuffer full_image (*mp_image);
|
tl::PixelBuffer full_image (*mp_image);
|
||||||
bitmaps_to_image (fg_view_op_vector (), fg_bitmap_vector (), dither_pattern (), line_styles (), &full_image, m_viewport_l.width (), m_viewport_l.height (), false, &m_mutex);
|
bitmaps_to_image (fg_view_op_vector (), fg_bitmap_vector (), dither_pattern (), line_styles (), &full_image, m_viewport_l.width (), m_viewport_l.height (), false, &m_mutex);
|
||||||
|
|
||||||
// render the foreground parts ..
|
// render the foreground parts ..
|
||||||
if (m_oversampling == 1) {
|
if (m_oversampling == 1) {
|
||||||
*mp_image_fg = full_image;
|
*mp_image_fg = full_image;
|
||||||
} else {
|
} else {
|
||||||
lay::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ());
|
tl::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ());
|
||||||
subsampled_image.set_transparent (mp_image->transparent ());
|
subsampled_image.set_transparent (mp_image->transparent ());
|
||||||
subsample (full_image, subsampled_image, m_oversampling, m_gamma);
|
subsample (full_image, subsampled_image, m_oversampling, m_gamma);
|
||||||
*mp_image_fg = subsampled_image;
|
*mp_image_fg = subsampled_image;
|
||||||
|
|
@ -645,7 +645,7 @@ LayoutCanvas::paint_event ()
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
lay::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ());
|
tl::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ());
|
||||||
subsampled_image.set_transparent (mp_image->transparent ());
|
subsampled_image.set_transparent (mp_image->transparent ());
|
||||||
subsample (*mp_image, subsampled_image, m_oversampling, m_gamma);
|
subsample (*mp_image, subsampled_image, m_oversampling, m_gamma);
|
||||||
*mp_image_fg = subsampled_image;
|
*mp_image_fg = subsampled_image;
|
||||||
|
|
@ -670,7 +670,7 @@ LayoutCanvas::paint_event ()
|
||||||
|
|
||||||
if (fg_bitmaps () > 0) {
|
if (fg_bitmaps () > 0) {
|
||||||
|
|
||||||
lay::PixelBuffer full_image (mp_image->width (), mp_image->height ());
|
tl::PixelBuffer full_image (mp_image->width (), mp_image->height ());
|
||||||
full_image.set_transparent (true);
|
full_image.set_transparent (true);
|
||||||
full_image.fill (0);
|
full_image.fill (0);
|
||||||
|
|
||||||
|
|
@ -684,7 +684,7 @@ LayoutCanvas::paint_event ()
|
||||||
#endif
|
#endif
|
||||||
painter.drawImage (QPoint (0, 0), img);
|
painter.drawImage (QPoint (0, 0), img);
|
||||||
} else {
|
} else {
|
||||||
lay::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ());
|
tl::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ());
|
||||||
subsampled_image.set_transparent (true);
|
subsampled_image.set_transparent (true);
|
||||||
subsample (full_image, subsampled_image, m_oversampling, m_gamma);
|
subsample (full_image, subsampled_image, m_oversampling, m_gamma);
|
||||||
QImage img = subsampled_image.to_image ();
|
QImage img = subsampled_image.to_image ();
|
||||||
|
|
@ -712,7 +712,7 @@ class DetachedViewObjectCanvas
|
||||||
: public BitmapViewObjectCanvas
|
: public BitmapViewObjectCanvas
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DetachedViewObjectCanvas (tl::Color bg, tl::Color fg, tl::Color ac, unsigned int width_l, unsigned int height_l, double resolution, lay::PixelBuffer *img)
|
DetachedViewObjectCanvas (tl::Color bg, tl::Color fg, tl::Color ac, unsigned int width_l, unsigned int height_l, double resolution, tl::PixelBuffer *img)
|
||||||
: BitmapViewObjectCanvas (width_l, height_l, resolution),
|
: BitmapViewObjectCanvas (width_l, height_l, resolution),
|
||||||
m_bg (bg), m_fg (fg), m_ac (ac), mp_image (img)
|
m_bg (bg), m_fg (fg), m_ac (ac), mp_image (img)
|
||||||
{
|
{
|
||||||
|
|
@ -720,7 +720,7 @@ public:
|
||||||
m_gamma = 2.0;
|
m_gamma = 2.0;
|
||||||
|
|
||||||
if (img->width () != width_l || img->height () != height_l) {
|
if (img->width () != width_l || img->height () != height_l) {
|
||||||
mp_image_l = new lay::PixelBuffer (width_l, height_l);
|
mp_image_l = new tl::PixelBuffer (width_l, height_l);
|
||||||
mp_image_l->set_transparent (img->transparent ());
|
mp_image_l->set_transparent (img->transparent ());
|
||||||
mp_image_l->fill (bg.rgb ());
|
mp_image_l->fill (bg.rgb ());
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -753,7 +753,7 @@ public:
|
||||||
return m_ac;
|
return m_ac;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual lay::PixelBuffer *bg_image ()
|
virtual tl::PixelBuffer *bg_image ()
|
||||||
{
|
{
|
||||||
return mp_image_l ? mp_image_l : mp_image;
|
return mp_image_l ? mp_image_l : mp_image;
|
||||||
}
|
}
|
||||||
|
|
@ -781,8 +781,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
tl::Color m_bg, m_fg, m_ac;
|
tl::Color m_bg, m_fg, m_ac;
|
||||||
lay::PixelBuffer *mp_image;
|
tl::PixelBuffer *mp_image;
|
||||||
lay::PixelBuffer *mp_image_l;
|
tl::PixelBuffer *mp_image_l;
|
||||||
double m_gamma;
|
double m_gamma;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -828,13 +828,13 @@ private:
|
||||||
bool m_bg, m_fg, m_ac;
|
bool m_bg, m_fg, m_ac;
|
||||||
};
|
};
|
||||||
|
|
||||||
lay::PixelBuffer
|
tl::PixelBuffer
|
||||||
LayoutCanvas::image (unsigned int width, unsigned int height)
|
LayoutCanvas::image (unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
return image_with_options (width, height, -1, -1, -1.0, tl::Color (), tl::Color (), tl::Color (), db::DBox ());
|
return image_with_options (width, height, -1, -1, -1.0, tl::Color (), tl::Color (), tl::Color (), db::DBox ());
|
||||||
}
|
}
|
||||||
|
|
||||||
lay::PixelBuffer
|
tl::PixelBuffer
|
||||||
LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box)
|
LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box)
|
||||||
{
|
{
|
||||||
if (oversampling <= 0) {
|
if (oversampling <= 0) {
|
||||||
|
|
@ -857,7 +857,7 @@ LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int l
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: for other architectures MonoLSB may not be the right format
|
// TODO: for other architectures MonoLSB may not be the right format
|
||||||
lay::PixelBuffer img (width, height);
|
tl::PixelBuffer img (width, height);
|
||||||
|
|
||||||
// this may happen for BIG images:
|
// this may happen for BIG images:
|
||||||
if (img.width () != width || img.height () != height) {
|
if (img.width () != width || img.height () != height) {
|
||||||
|
|
@ -910,7 +910,7 @@ LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int l
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
lay::BitmapBuffer
|
tl::BitmapBuffer
|
||||||
LayoutCanvas::image_with_options_mono (unsigned int width, unsigned int height, int linewidth, tl::Color background_c, tl::Color foreground_c, tl::Color active_c, const db::DBox &target_box)
|
LayoutCanvas::image_with_options_mono (unsigned int width, unsigned int height, int linewidth, tl::Color background_c, tl::Color foreground_c, tl::Color active_c, const db::DBox &target_box)
|
||||||
{
|
{
|
||||||
if (linewidth <= 0) {
|
if (linewidth <= 0) {
|
||||||
|
|
@ -946,7 +946,7 @@ LayoutCanvas::image_with_options_mono (unsigned int width, unsigned int height,
|
||||||
redraw_thread.start (0 /*synchronous*/, m_layers, vp, 1.0, true);
|
redraw_thread.start (0 /*synchronous*/, m_layers, vp, 1.0, true);
|
||||||
redraw_thread.stop (); // safety
|
redraw_thread.stop (); // safety
|
||||||
|
|
||||||
lay::BitmapBuffer img (width, height);
|
tl::BitmapBuffer img (width, height);
|
||||||
img.fill (background);
|
img.fill (background);
|
||||||
|
|
||||||
rd_canvas.to_image_mono (view_ops, dither_pattern (), line_styles (), background, foreground, active, this, img, vp.width (), vp.height ());
|
rd_canvas.to_image_mono (view_ops, dither_pattern (), line_styles (), background, foreground, active, this, img, vp.width (), vp.height ());
|
||||||
|
|
@ -954,13 +954,13 @@ LayoutCanvas::image_with_options_mono (unsigned int width, unsigned int height,
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
lay::PixelBuffer
|
tl::PixelBuffer
|
||||||
LayoutCanvas::screenshot ()
|
LayoutCanvas::screenshot ()
|
||||||
{
|
{
|
||||||
// if required, start the redraw thread ..
|
// if required, start the redraw thread ..
|
||||||
prepare_drawing ();
|
prepare_drawing ();
|
||||||
|
|
||||||
lay::PixelBuffer img (m_viewport.width (), m_viewport.height ());
|
tl::PixelBuffer img (m_viewport.width (), m_viewport.height ());
|
||||||
img.fill (m_background);
|
img.fill (m_background);
|
||||||
|
|
||||||
DetachedViewObjectCanvas vo_canvas (background_color (), foreground_color (), active_color (), m_viewport_l.width (), m_viewport_l.height (), 1.0 / double (m_oversampling * m_dpr), &img);
|
DetachedViewObjectCanvas vo_canvas (background_color (), foreground_color (), active_color (), m_viewport_l.width (), m_viewport_l.height (), 1.0 / double (m_oversampling * m_dpr), &img);
|
||||||
|
|
|
||||||
|
|
@ -164,10 +164,10 @@ public:
|
||||||
return m_view_ops;
|
return m_view_ops;
|
||||||
}
|
}
|
||||||
|
|
||||||
lay::PixelBuffer screenshot ();
|
tl::PixelBuffer screenshot ();
|
||||||
lay::PixelBuffer image (unsigned int width, unsigned int height);
|
tl::PixelBuffer image (unsigned int width, unsigned int height);
|
||||||
lay::PixelBuffer image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box);
|
tl::PixelBuffer image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box);
|
||||||
lay::BitmapBuffer image_with_options_mono (unsigned int width, unsigned int height, int linewidth, tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box);
|
tl::BitmapBuffer image_with_options_mono (unsigned int width, unsigned int height, int linewidth, tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box);
|
||||||
|
|
||||||
void update_image ();
|
void update_image ();
|
||||||
|
|
||||||
|
|
@ -312,7 +312,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief Reimplementation of ViewObjectCanvas: background image
|
* @brief Reimplementation of ViewObjectCanvas: background image
|
||||||
*/
|
*/
|
||||||
lay::PixelBuffer *bg_image ()
|
tl::PixelBuffer *bg_image ()
|
||||||
{
|
{
|
||||||
return mp_image;
|
return mp_image;
|
||||||
}
|
}
|
||||||
|
|
@ -358,9 +358,9 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
lay::LayoutViewBase *mp_view;
|
lay::LayoutViewBase *mp_view;
|
||||||
lay::PixelBuffer *mp_image;
|
tl::PixelBuffer *mp_image;
|
||||||
lay::PixelBuffer *mp_image_bg;
|
tl::PixelBuffer *mp_image_bg;
|
||||||
lay::PixelBuffer *mp_image_fg;
|
tl::PixelBuffer *mp_image_fg;
|
||||||
db::DBox m_precious_box;
|
db::DBox m_precious_box;
|
||||||
lay::Viewport m_viewport, m_viewport_l;
|
lay::Viewport m_viewport, m_viewport_l;
|
||||||
tl::color_t m_background;
|
tl::color_t m_background;
|
||||||
|
|
|
||||||
|
|
@ -2534,7 +2534,7 @@ LayoutViewBase::get_screenshot ()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
lay::PixelBuffer
|
tl::PixelBuffer
|
||||||
LayoutViewBase::get_screenshot_pb ()
|
LayoutViewBase::get_screenshot_pb ()
|
||||||
{
|
{
|
||||||
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save screenshot")));
|
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save screenshot")));
|
||||||
|
|
@ -2597,7 +2597,7 @@ LayoutViewBase::save_screenshot (const std::string &fn)
|
||||||
tl::DeferredMethodScheduler::execute ();
|
tl::DeferredMethodScheduler::execute ();
|
||||||
|
|
||||||
tl::OutputStream stream (fn);
|
tl::OutputStream stream (fn);
|
||||||
lay::PixelBuffer img = mp_canvas->screenshot ();
|
tl::PixelBuffer img = mp_canvas->screenshot ();
|
||||||
img.set_texts (png_texts (this, box ()));
|
img.set_texts (png_texts (this, box ()));
|
||||||
img.write_png (stream);
|
img.write_png (stream);
|
||||||
|
|
||||||
|
|
@ -2624,7 +2624,7 @@ LayoutViewBase::get_image (unsigned int width, unsigned int height)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
lay::PixelBuffer
|
tl::PixelBuffer
|
||||||
LayoutViewBase::get_pixels (unsigned int width, unsigned int height)
|
LayoutViewBase::get_pixels (unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image")));
|
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image")));
|
||||||
|
|
@ -2653,7 +2653,7 @@ LayoutViewBase::get_image_with_options (unsigned int width, unsigned int height,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
lay::PixelBuffer
|
tl::PixelBuffer
|
||||||
LayoutViewBase::get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution,
|
LayoutViewBase::get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution,
|
||||||
tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box)
|
tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box)
|
||||||
{
|
{
|
||||||
|
|
@ -2665,7 +2665,7 @@ LayoutViewBase::get_pixels_with_options (unsigned int width, unsigned int height
|
||||||
return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box);
|
return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box);
|
||||||
}
|
}
|
||||||
|
|
||||||
lay::BitmapBuffer
|
tl::BitmapBuffer
|
||||||
LayoutViewBase::get_pixels_with_options_mono (unsigned int width, unsigned int height, int linewidth,
|
LayoutViewBase::get_pixels_with_options_mono (unsigned int width, unsigned int height, int linewidth,
|
||||||
tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box)
|
tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box)
|
||||||
{
|
{
|
||||||
|
|
@ -2712,7 +2712,7 @@ LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned
|
||||||
tl::DeferredMethodScheduler::execute ();
|
tl::DeferredMethodScheduler::execute ();
|
||||||
|
|
||||||
tl::OutputStream stream (fn);
|
tl::OutputStream stream (fn);
|
||||||
lay::PixelBuffer img = mp_canvas->image (width, height);
|
tl::PixelBuffer img = mp_canvas->image (width, height);
|
||||||
std::vector<std::pair<std::string, std::string> > texts = png_texts (this, vp.box ());
|
std::vector<std::pair<std::string, std::string> > texts = png_texts (this, vp.box ());
|
||||||
img.set_texts (texts);
|
img.set_texts (texts);
|
||||||
img.write_png (stream);
|
img.write_png (stream);
|
||||||
|
|
@ -2775,13 +2775,13 @@ LayoutViewBase::save_image_with_options (const std::string &fn,
|
||||||
tl::OutputStream stream (fn);
|
tl::OutputStream stream (fn);
|
||||||
if (monochrome) {
|
if (monochrome) {
|
||||||
|
|
||||||
lay::BitmapBuffer img = mp_canvas->image_with_options_mono (width, height, linewidth, background, foreground, active, target_box);
|
tl::BitmapBuffer img = mp_canvas->image_with_options_mono (width, height, linewidth, background, foreground, active, target_box);
|
||||||
img.set_texts (texts);
|
img.set_texts (texts);
|
||||||
img.write_png (stream);
|
img.write_png (stream);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
lay::PixelBuffer img = mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box);
|
tl::PixelBuffer img = mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box);
|
||||||
img.set_texts (texts);
|
img.set_texts (texts);
|
||||||
img.write_png (stream);
|
img.write_png (stream);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -837,9 +837,9 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets the screen content as a lay::PixelBuffer object
|
* @brief Gets the screen content as a tl::PixelBuffer object
|
||||||
*/
|
*/
|
||||||
lay::PixelBuffer get_screenshot_pb ();
|
tl::PixelBuffer get_screenshot_pb ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Save an image file with the given width and height
|
* @brief Save an image file with the given width and height
|
||||||
|
|
@ -871,9 +871,9 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets the screen content as a lay::PixelBuffer object
|
* @brief Gets the screen content as a tl::PixelBuffer object
|
||||||
*/
|
*/
|
||||||
lay::PixelBuffer get_pixels (unsigned int width, unsigned int height);
|
tl::PixelBuffer get_pixels (unsigned int width, unsigned int height);
|
||||||
|
|
||||||
#if defined(HAVE_QT)
|
#if defined(HAVE_QT)
|
||||||
/**
|
/**
|
||||||
|
|
@ -894,7 +894,7 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the screen content as a lay::PixelBuffer object with the given width and height
|
* @brief Get the screen content as a tl::PixelBuffer object with the given width and height
|
||||||
*
|
*
|
||||||
* @param width The width of the image in pixels
|
* @param width The width of the image in pixels
|
||||||
* @param height The height of the image
|
* @param height The height of the image
|
||||||
|
|
@ -906,10 +906,10 @@ public:
|
||||||
* @param active The active color or tl::Color() for default
|
* @param active The active color or tl::Color() for default
|
||||||
* @param target_box The box to draw or db::DBox() for default
|
* @param target_box The box to draw or db::DBox() for default
|
||||||
*/
|
*/
|
||||||
lay::PixelBuffer get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box);
|
tl::PixelBuffer get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the screen content as a monochrome lay::BitmapBuffer object with the given options
|
* @brief Get the screen content as a monochrome tl::BitmapBuffer object with the given options
|
||||||
*
|
*
|
||||||
* @param width The width of the image in pixels
|
* @param width The width of the image in pixels
|
||||||
* @param height The height of the image
|
* @param height The height of the image
|
||||||
|
|
@ -923,7 +923,7 @@ public:
|
||||||
*
|
*
|
||||||
* The colors will are converted to "on" pixels with a green channel value >= 50%.
|
* The colors will are converted to "on" pixels with a green channel value >= 50%.
|
||||||
*/
|
*/
|
||||||
lay::BitmapBuffer get_pixels_with_options_mono (unsigned int width, unsigned int height, int linewidth, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box);
|
tl::BitmapBuffer get_pixels_with_options_mono (unsigned int width, unsigned int height, int linewidth, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Hierarchy level selection setter
|
* @brief Hierarchy level selection setter
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,12 @@
|
||||||
#include "layPixelBufferPainter.h"
|
#include "layPixelBufferPainter.h"
|
||||||
|
|
||||||
#include "layFixedFont.h"
|
#include "layFixedFont.h"
|
||||||
#include "layPixelBuffer.h"
|
#include "tlPixelBuffer.h"
|
||||||
|
|
||||||
namespace lay
|
namespace lay
|
||||||
{
|
{
|
||||||
|
|
||||||
PixelBufferPainter::PixelBufferPainter (lay::PixelBuffer &img, unsigned int width, unsigned int height, double resolution)
|
PixelBufferPainter::PixelBufferPainter (tl::PixelBuffer &img, unsigned int width, unsigned int height, double resolution)
|
||||||
: mp_img (&img),
|
: mp_img (&img),
|
||||||
m_resolution (resolution), m_width (width), m_height (height)
|
m_resolution (resolution), m_width (width), m_height (height)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,15 @@
|
||||||
#include "tlColor.h"
|
#include "tlColor.h"
|
||||||
#include "dbPoint.h"
|
#include "dbPoint.h"
|
||||||
|
|
||||||
|
namespace tl
|
||||||
|
{
|
||||||
|
class PixelBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
namespace lay {
|
namespace lay {
|
||||||
|
|
||||||
class PixelBuffer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A very simplistic painter for lay::PixelBuffer
|
* @brief A very simplistic painter for tl::PixelBuffer
|
||||||
*
|
*
|
||||||
* This painter supports very few primitives currently and is used to paint the
|
* This painter supports very few primitives currently and is used to paint the
|
||||||
* background grid for example.
|
* background grid for example.
|
||||||
|
|
@ -41,7 +44,7 @@ class PixelBuffer;
|
||||||
class LAYBASIC_PUBLIC PixelBufferPainter
|
class LAYBASIC_PUBLIC PixelBufferPainter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PixelBufferPainter (lay::PixelBuffer &img, unsigned int width, unsigned int height, double resolution);
|
PixelBufferPainter (tl::PixelBuffer &img, unsigned int width, unsigned int height, double resolution);
|
||||||
|
|
||||||
void set (const db::Point &p, tl::Color c);
|
void set (const db::Point &p, tl::Color c);
|
||||||
void draw_line (const db::Point &p1, const db::Point &p2, tl::Color c);
|
void draw_line (const db::Point &p1, const db::Point &p2, tl::Color c);
|
||||||
|
|
@ -50,7 +53,7 @@ public:
|
||||||
void draw_text (const char *t, const db::Point &p, tl::Color c, int halign, int valign);
|
void draw_text (const char *t, const db::Point &p, tl::Color c, int halign, int valign);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
lay::PixelBuffer *mp_img;
|
tl::PixelBuffer *mp_img;
|
||||||
double m_resolution;
|
double m_resolution;
|
||||||
int m_width, m_height;
|
int m_width, m_height;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -392,7 +392,7 @@ BitmapRedrawThreadCanvas::initialize_plane (lay::CanvasPlane *plane, unsigned in
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BitmapRedrawThreadCanvas::to_image (const std::vector <lay::ViewOp> &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, tl::Color background, tl::Color foreground, tl::Color active, const lay::Drawings *drawings, lay::PixelBuffer &img, unsigned int width, unsigned int height)
|
BitmapRedrawThreadCanvas::to_image (const std::vector <lay::ViewOp> &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, tl::Color background, tl::Color foreground, tl::Color active, const lay::Drawings *drawings, tl::PixelBuffer &img, unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
if (width > m_width) {
|
if (width > m_width) {
|
||||||
width = m_width;
|
width = m_width;
|
||||||
|
|
@ -412,7 +412,7 @@ BitmapRedrawThreadCanvas::to_image (const std::vector <lay::ViewOp> &view_ops, c
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BitmapRedrawThreadCanvas::to_image_mono (const std::vector <lay::ViewOp> &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, bool background, bool foreground, bool active, const lay::Drawings *drawings, lay::BitmapBuffer &img, unsigned int width, unsigned int height)
|
BitmapRedrawThreadCanvas::to_image_mono (const std::vector <lay::ViewOp> &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, bool background, bool foreground, bool active, const lay::Drawings *drawings, tl::BitmapBuffer &img, unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
if (width > m_width) {
|
if (width > m_width) {
|
||||||
width = m_width;
|
width = m_width;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
#include "dbTrans.h"
|
#include "dbTrans.h"
|
||||||
#include "layViewOp.h"
|
#include "layViewOp.h"
|
||||||
#include "layBitmapRenderer.h"
|
#include "layBitmapRenderer.h"
|
||||||
#include "layPixelBuffer.h"
|
#include "tlPixelBuffer.h"
|
||||||
#include "tlThreads.h"
|
#include "tlThreads.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
@ -319,12 +319,12 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief Transfer the content to a PixelBuffer
|
* @brief Transfer the content to a PixelBuffer
|
||||||
*/
|
*/
|
||||||
void to_image (const std::vector <lay::ViewOp> &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, tl::Color background, tl::Color foreground, tl::Color active, const lay::Drawings *drawings, PixelBuffer &img, unsigned int width, unsigned int height);
|
void to_image (const std::vector <lay::ViewOp> &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, tl::Color background, tl::Color foreground, tl::Color active, const lay::Drawings *drawings, tl::PixelBuffer &img, unsigned int width, unsigned int height);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Transfer the content to a BitmapBuffer (monochrome)
|
* @brief Transfer the content to a BitmapBuffer (monochrome)
|
||||||
*/
|
*/
|
||||||
void to_image_mono (const std::vector <lay::ViewOp> &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, bool background, bool foreground, bool active, const lay::Drawings *drawings, lay::BitmapBuffer &img, unsigned int width, unsigned int height);
|
void to_image_mono (const std::vector <lay::ViewOp> &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, bool background, bool foreground, bool active, const lay::Drawings *drawings, tl::BitmapBuffer &img, unsigned int width, unsigned int height);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets the current bitmap data as a BitmapCanvasData object
|
* @brief Gets the current bitmap data as a BitmapCanvasData object
|
||||||
|
|
|
||||||
|
|
@ -1357,13 +1357,13 @@ BitmapViewObjectCanvas::set_size (double resolution)
|
||||||
m_resolution = resolution;
|
m_resolution = resolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
lay::PixelBuffer *
|
tl::PixelBuffer *
|
||||||
BitmapViewObjectCanvas::bg_image ()
|
BitmapViewObjectCanvas::bg_image ()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
lay::BitmapBuffer *
|
tl::BitmapBuffer *
|
||||||
BitmapViewObjectCanvas::bg_bitmap ()
|
BitmapViewObjectCanvas::bg_bitmap ()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,12 @@ namespace db
|
||||||
class Layout;
|
class Layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace tl
|
||||||
|
{
|
||||||
|
class PixelBuffer;
|
||||||
|
class BitmapBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
namespace lay {
|
namespace lay {
|
||||||
|
|
||||||
class Viewport;
|
class Viewport;
|
||||||
|
|
@ -70,8 +76,6 @@ class ViewObjectUI;
|
||||||
class ViewObjectCanvas;
|
class ViewObjectCanvas;
|
||||||
class CanvasPlane;
|
class CanvasPlane;
|
||||||
class Bitmap;
|
class Bitmap;
|
||||||
class PixelBuffer;
|
|
||||||
class BitmapBuffer;
|
|
||||||
|
|
||||||
#if defined(HAVE_QT)
|
#if defined(HAVE_QT)
|
||||||
class DragDropDataBase;
|
class DragDropDataBase;
|
||||||
|
|
@ -1323,12 +1327,12 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief Gets the pixel buffer that background objects render to
|
* @brief Gets the pixel buffer that background objects render to
|
||||||
*/
|
*/
|
||||||
virtual lay::PixelBuffer *bg_image ();
|
virtual tl::PixelBuffer *bg_image ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets the monochrome pixel buffer that background objects render to
|
* @brief Gets the monochrome pixel buffer that background objects render to
|
||||||
*/
|
*/
|
||||||
virtual lay::BitmapBuffer *bg_bitmap ();
|
virtual tl::BitmapBuffer *bg_bitmap ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map <lay::ViewOp, unsigned int> m_fg_bitmap_table;
|
std::map <lay::ViewOp, unsigned int> m_fg_bitmap_table;
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ SOURCES += \
|
||||||
gsiDeclLayLayoutViewBase.cc \
|
gsiDeclLayLayoutViewBase.cc \
|
||||||
gsiDeclLayMarker.cc \
|
gsiDeclLayMarker.cc \
|
||||||
gsiDeclLayPlugin.cc \
|
gsiDeclLayPlugin.cc \
|
||||||
gsiDeclLayPixelBuffer.cc \
|
|
||||||
laybasicForceLink.cc \
|
laybasicForceLink.cc \
|
||||||
layAnnotationShapes.cc \
|
layAnnotationShapes.cc \
|
||||||
layBitmap.cc \
|
layBitmap.cc \
|
||||||
|
|
@ -64,7 +63,6 @@ SOURCES += \
|
||||||
layNetColorizer.cc \
|
layNetColorizer.cc \
|
||||||
layObjectInstPath.cc \
|
layObjectInstPath.cc \
|
||||||
layParsedLayerSource.cc \
|
layParsedLayerSource.cc \
|
||||||
layPixelBuffer.cc \
|
|
||||||
layPixelBufferPainter.cc \
|
layPixelBufferPainter.cc \
|
||||||
layPlugin.cc \
|
layPlugin.cc \
|
||||||
layRedrawLayerInfo.cc \
|
layRedrawLayerInfo.cc \
|
||||||
|
|
@ -116,7 +114,7 @@ HEADERS += \
|
||||||
layNetColorizer.h \
|
layNetColorizer.h \
|
||||||
layObjectInstPath.h \
|
layObjectInstPath.h \
|
||||||
layParsedLayerSource.h \
|
layParsedLayerSource.h \
|
||||||
layPixelBuffer.h \
|
tlPixelBuffer.h \
|
||||||
layPixelBufferPainter.h \
|
layPixelBufferPainter.h \
|
||||||
layPlugin.h \
|
layPlugin.h \
|
||||||
layRedrawLayerInfo.h \
|
layRedrawLayerInfo.h \
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,11 @@
|
||||||
#include "layBitmap.h"
|
#include "layBitmap.h"
|
||||||
#include "layDitherPattern.h"
|
#include "layDitherPattern.h"
|
||||||
#include "layLineStyles.h"
|
#include "layLineStyles.h"
|
||||||
#include "layPixelBuffer.h"
|
#include "tlPixelBuffer.h"
|
||||||
#include "tlUnitTest.h"
|
#include "tlUnitTest.h"
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
to_string (const lay::PixelBuffer &img, unsigned int mask)
|
to_string (const tl::PixelBuffer &img, unsigned int mask)
|
||||||
{
|
{
|
||||||
std::string s;
|
std::string s;
|
||||||
for (unsigned int i = 0; i < 32; ++i) {
|
for (unsigned int i = 0; i < 32; ++i) {
|
||||||
|
|
@ -85,7 +85,7 @@ TEST(1)
|
||||||
view_ops.push_back (lay::ViewOp (0x000080, lay::ViewOp::Copy, 0, 0, 0, lay::ViewOp::Rect, 1));
|
view_ops.push_back (lay::ViewOp (0x000080, lay::ViewOp::Copy, 0, 0, 0, lay::ViewOp::Rect, 1));
|
||||||
view_ops.push_back (lay::ViewOp (0x0000c0, lay::ViewOp::Or, 0, 0, 0, lay::ViewOp::Rect, 3));
|
view_ops.push_back (lay::ViewOp (0x0000c0, lay::ViewOp::Or, 0, 0, 0, lay::ViewOp::Rect, 3));
|
||||||
|
|
||||||
lay::PixelBuffer img (32, 32);
|
tl::PixelBuffer img (32, 32);
|
||||||
img.fill (0);
|
img.fill (0);
|
||||||
|
|
||||||
lay::DitherPattern dp;
|
lay::DitherPattern dp;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ SOURCES = \
|
||||||
layBitmapsToImage.cc \
|
layBitmapsToImage.cc \
|
||||||
layLayerProperties.cc \
|
layLayerProperties.cc \
|
||||||
layParsedLayerSource.cc \
|
layParsedLayerSource.cc \
|
||||||
layPixelBufferTests.cc \
|
|
||||||
layRenderer.cc \
|
layRenderer.cc \
|
||||||
layAbstractMenuTests.cc \
|
layAbstractMenuTests.cc \
|
||||||
laySnapTests.cc
|
laySnapTests.cc
|
||||||
|
|
|
||||||
|
|
@ -530,7 +530,7 @@ LayerTreeModel::parent (const QModelIndex &index) const
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
single_bitmap_to_image (const lay::ViewOp &view_op, lay::Bitmap &bitmap,
|
single_bitmap_to_image (const lay::ViewOp &view_op, lay::Bitmap &bitmap,
|
||||||
lay::PixelBuffer *pimage, const lay::DitherPattern &dither_pattern, const lay::LineStyles &line_styles,
|
tl::PixelBuffer *pimage, const lay::DitherPattern &dither_pattern, const lay::LineStyles &line_styles,
|
||||||
unsigned int width, unsigned int height)
|
unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
std::vector <lay::ViewOp> view_ops;
|
std::vector <lay::ViewOp> view_ops;
|
||||||
|
|
@ -647,7 +647,7 @@ LayerTreeModel::icon_for_layer (const lay::LayerPropertiesConstIterator &iter, l
|
||||||
tl::color_t fill_color = iter->has_fill_color (true) ? iter->eff_fill_color (true) : def_color;
|
tl::color_t fill_color = iter->has_fill_color (true) ? iter->eff_fill_color (true) : def_color;
|
||||||
tl::color_t frame_color = iter->has_frame_color (true) ? iter->eff_frame_color (true) : def_color;
|
tl::color_t frame_color = iter->has_frame_color (true) ? iter->eff_frame_color (true) : def_color;
|
||||||
|
|
||||||
lay::PixelBuffer image (w, h);
|
tl::PixelBuffer image (w, h);
|
||||||
image.set_transparent (true);
|
image.set_transparent (true);
|
||||||
image.fill (view->background_color ().rgb ());
|
image.fill (view->background_color ().rgb ());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,12 +72,12 @@ static bool compare_images_mono (const QImage &qimg, const std::string &au)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool compare_images (const lay::PixelBuffer &img, const lay::PixelBuffer &img2)
|
static bool compare_images (const tl::PixelBuffer &img, const tl::PixelBuffer &img2)
|
||||||
{
|
{
|
||||||
return img == img2;
|
return img == img2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool compare_images (const lay::BitmapBuffer &img, const lay::BitmapBuffer &img2)
|
static bool compare_images (const tl::BitmapBuffer &img, const tl::BitmapBuffer &img2)
|
||||||
{
|
{
|
||||||
return img == img2;
|
return img == img2;
|
||||||
}
|
}
|
||||||
|
|
@ -162,7 +162,7 @@ TEST(4)
|
||||||
lv.resize (42, 117);
|
lv.resize (42, 117);
|
||||||
tl::msleep (250);
|
tl::msleep (250);
|
||||||
|
|
||||||
lay::PixelBuffer img = lv.get_screenshot_pb ();
|
tl::PixelBuffer img = lv.get_screenshot_pb ();
|
||||||
EXPECT_EQ ((int) img.width (), 42);
|
EXPECT_EQ ((int) img.width (), 42);
|
||||||
EXPECT_EQ ((int) img.height (), 117);
|
EXPECT_EQ ((int) img.height (), 117);
|
||||||
|
|
||||||
|
|
@ -181,7 +181,7 @@ TEST(11)
|
||||||
|
|
||||||
lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true);
|
lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true);
|
||||||
|
|
||||||
lay::PixelBuffer img;
|
tl::PixelBuffer img;
|
||||||
img = lv.get_pixels_with_options (500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox ());
|
img = lv.get_pixels_with_options (500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox ());
|
||||||
|
|
||||||
std::string tmp = tmp_file ("test.png");
|
std::string tmp = tmp_file ("test.png");
|
||||||
|
|
@ -192,10 +192,10 @@ TEST(11)
|
||||||
tl::info << "PNG file written to " << tmp;
|
tl::info << "PNG file written to " << tmp;
|
||||||
|
|
||||||
std::string au = tl::testsrc () + "/testdata/lay/au_lv1.png";
|
std::string au = tl::testsrc () + "/testdata/lay/au_lv1.png";
|
||||||
lay::PixelBuffer au_img;
|
tl::PixelBuffer au_img;
|
||||||
{
|
{
|
||||||
tl::InputStream stream (au);
|
tl::InputStream stream (au);
|
||||||
au_img = lay::PixelBuffer::read_png (stream);
|
au_img = tl::PixelBuffer::read_png (stream);
|
||||||
}
|
}
|
||||||
tl::info << "PNG file read from " << au;
|
tl::info << "PNG file read from " << au;
|
||||||
|
|
||||||
|
|
@ -209,7 +209,7 @@ TEST(12)
|
||||||
|
|
||||||
lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true);
|
lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true);
|
||||||
|
|
||||||
lay::PixelBuffer img;
|
tl::PixelBuffer img;
|
||||||
img = lv.get_pixels_with_options (500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox ());
|
img = lv.get_pixels_with_options (500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox ());
|
||||||
|
|
||||||
std::string tmp = tmp_file ("test.png");
|
std::string tmp = tmp_file ("test.png");
|
||||||
|
|
@ -220,10 +220,10 @@ TEST(12)
|
||||||
tl::info << "PNG file written to " << tmp;
|
tl::info << "PNG file written to " << tmp;
|
||||||
|
|
||||||
std::string au = tl::testsrc () + "/testdata/lay/au_lv2.png";
|
std::string au = tl::testsrc () + "/testdata/lay/au_lv2.png";
|
||||||
lay::PixelBuffer au_img;
|
tl::PixelBuffer au_img;
|
||||||
{
|
{
|
||||||
tl::InputStream stream (au);
|
tl::InputStream stream (au);
|
||||||
au_img = lay::PixelBuffer::read_png (stream);
|
au_img = tl::PixelBuffer::read_png (stream);
|
||||||
}
|
}
|
||||||
tl::info << "PNG file read from " << au;
|
tl::info << "PNG file read from " << au;
|
||||||
|
|
||||||
|
|
@ -238,7 +238,7 @@ TEST(13)
|
||||||
|
|
||||||
lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true);
|
lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true);
|
||||||
|
|
||||||
lay::BitmapBuffer img;
|
tl::BitmapBuffer img;
|
||||||
img = lv.get_pixels_with_options_mono (500, 500, 1, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox ());
|
img = lv.get_pixels_with_options_mono (500, 500, 1, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox ());
|
||||||
|
|
||||||
std::string tmp = tmp_file ("test.png");
|
std::string tmp = tmp_file ("test.png");
|
||||||
|
|
@ -249,10 +249,10 @@ TEST(13)
|
||||||
tl::info << "PNG file written to " << tmp;
|
tl::info << "PNG file written to " << tmp;
|
||||||
|
|
||||||
std::string au = tl::testsrc () + "/testdata/lay/au_lv3.png";
|
std::string au = tl::testsrc () + "/testdata/lay/au_lv3.png";
|
||||||
lay::BitmapBuffer au_img;
|
tl::BitmapBuffer au_img;
|
||||||
{
|
{
|
||||||
tl::InputStream stream (au);
|
tl::InputStream stream (au);
|
||||||
au_img = lay::BitmapBuffer::read_png (stream);
|
au_img = tl::BitmapBuffer::read_png (stream);
|
||||||
}
|
}
|
||||||
tl::info << "PNG file read from " << au;
|
tl::info << "PNG file read from " << au;
|
||||||
|
|
||||||
|
|
@ -271,18 +271,18 @@ TEST(21)
|
||||||
std::string tmp = tmp_file ("test.png");
|
std::string tmp = tmp_file ("test.png");
|
||||||
lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), false);
|
lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), false);
|
||||||
|
|
||||||
lay::PixelBuffer img;
|
tl::PixelBuffer img;
|
||||||
{
|
{
|
||||||
tl::InputStream stream (tmp);
|
tl::InputStream stream (tmp);
|
||||||
img = lay::PixelBuffer::read_png (stream);
|
img = tl::PixelBuffer::read_png (stream);
|
||||||
}
|
}
|
||||||
tl::info << "PNG file read from " << tmp;
|
tl::info << "PNG file read from " << tmp;
|
||||||
|
|
||||||
std::string au = tl::testsrc () + "/testdata/lay/au_lv1.png";
|
std::string au = tl::testsrc () + "/testdata/lay/au_lv1.png";
|
||||||
lay::PixelBuffer au_img;
|
tl::PixelBuffer au_img;
|
||||||
{
|
{
|
||||||
tl::InputStream stream (au);
|
tl::InputStream stream (au);
|
||||||
au_img = lay::PixelBuffer::read_png (stream);
|
au_img = tl::PixelBuffer::read_png (stream);
|
||||||
}
|
}
|
||||||
tl::info << "PNG file read from " << au;
|
tl::info << "PNG file read from " << au;
|
||||||
|
|
||||||
|
|
@ -299,18 +299,18 @@ TEST(22)
|
||||||
std::string tmp = tmp_file ("test.png");
|
std::string tmp = tmp_file ("test.png");
|
||||||
lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), false);
|
lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), false);
|
||||||
|
|
||||||
lay::PixelBuffer img;
|
tl::PixelBuffer img;
|
||||||
{
|
{
|
||||||
tl::InputStream stream (tmp);
|
tl::InputStream stream (tmp);
|
||||||
img = lay::PixelBuffer::read_png (stream);
|
img = tl::PixelBuffer::read_png (stream);
|
||||||
}
|
}
|
||||||
tl::info << "PNG file read from " << tmp;
|
tl::info << "PNG file read from " << tmp;
|
||||||
|
|
||||||
std::string au = tl::testsrc () + "/testdata/lay/au_lv2.png";
|
std::string au = tl::testsrc () + "/testdata/lay/au_lv2.png";
|
||||||
lay::PixelBuffer au_img;
|
tl::PixelBuffer au_img;
|
||||||
{
|
{
|
||||||
tl::InputStream stream (au);
|
tl::InputStream stream (au);
|
||||||
au_img = lay::PixelBuffer::read_png (stream);
|
au_img = tl::PixelBuffer::read_png (stream);
|
||||||
}
|
}
|
||||||
tl::info << "PNG file read from " << au;
|
tl::info << "PNG file read from " << au;
|
||||||
|
|
||||||
|
|
@ -328,18 +328,18 @@ TEST(23)
|
||||||
std::string tmp = tmp_file ("test.png");
|
std::string tmp = tmp_file ("test.png");
|
||||||
lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), true);
|
lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), true);
|
||||||
|
|
||||||
lay::BitmapBuffer img;
|
tl::BitmapBuffer img;
|
||||||
{
|
{
|
||||||
tl::InputStream stream (tmp);
|
tl::InputStream stream (tmp);
|
||||||
img = lay::BitmapBuffer::read_png (stream);
|
img = tl::BitmapBuffer::read_png (stream);
|
||||||
}
|
}
|
||||||
tl::info << "PNG file read from " << tmp;
|
tl::info << "PNG file read from " << tmp;
|
||||||
|
|
||||||
std::string au = tl::testsrc () + "/testdata/lay/au_lv3.png";
|
std::string au = tl::testsrc () + "/testdata/lay/au_lv3.png";
|
||||||
lay::BitmapBuffer au_img;
|
tl::BitmapBuffer au_img;
|
||||||
{
|
{
|
||||||
tl::InputStream stream (au);
|
tl::InputStream stream (au);
|
||||||
au_img = lay::BitmapBuffer::read_png (stream);
|
au_img = tl::BitmapBuffer::read_png (stream);
|
||||||
}
|
}
|
||||||
tl::info << "PNG file read from " << au;
|
tl::info << "PNG file read from " << au;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -821,6 +821,30 @@ Class<rdb::Item> decl_RdbItem ("rdb", "RdbItem",
|
||||||
"@brief Sets the image from a string\n"
|
"@brief Sets the image from a string\n"
|
||||||
"@param image A base64-encoded image file (preferably in PNG format)\n"
|
"@param image A base64-encoded image file (preferably in PNG format)\n"
|
||||||
) +
|
) +
|
||||||
|
#if defined(HAVE_QTBINDINGS)
|
||||||
|
gsi::method ("image", &rdb::Item::image,
|
||||||
|
"@brief Gets the attached image as a QImage object\n"
|
||||||
|
"\n"
|
||||||
|
"This method has been added in version 0.28."
|
||||||
|
) +
|
||||||
|
gsi::method ("image=", static_cast<void (rdb::Item::*) (const QImage &)> (&rdb::Item::set_image),
|
||||||
|
"@brief Sets the attached image from a QImage object\n"
|
||||||
|
"\n"
|
||||||
|
"This method has been added in version 0.28."
|
||||||
|
) +
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_PNG)
|
||||||
|
gsi::method ("image_pixels", &rdb::Item::image_pixels,
|
||||||
|
"@brief Gets the attached image as a PixelBuffer object\n"
|
||||||
|
"\n"
|
||||||
|
"This method has been added in version 0.28."
|
||||||
|
) +
|
||||||
|
gsi::method ("image=", static_cast<void (rdb::Item::*) (const tl::PixelBuffer &)> (&rdb::Item::set_image),
|
||||||
|
"@brief Sets the attached image from a PixelBuffer object\n"
|
||||||
|
"\n"
|
||||||
|
"This method has been added in version 0.28."
|
||||||
|
) +
|
||||||
|
#endif
|
||||||
/* Not supported yet:
|
/* Not supported yet:
|
||||||
gsi::method ("multiplicity", &rdb::Item::multiplicity,
|
gsi::method ("multiplicity", &rdb::Item::multiplicity,
|
||||||
"@brief Gets the item's multiplicity\n"
|
"@brief Gets the item's multiplicity\n"
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
#include "tlAssert.h"
|
#include "tlAssert.h"
|
||||||
#include "tlStream.h"
|
#include "tlStream.h"
|
||||||
#include "tlLog.h"
|
#include "tlLog.h"
|
||||||
|
#include "tlBase64.h"
|
||||||
#include "dbPolygon.h"
|
#include "dbPolygon.h"
|
||||||
#include "dbBox.h"
|
#include "dbBox.h"
|
||||||
#include "dbEdge.h"
|
#include "dbEdge.h"
|
||||||
|
|
@ -961,7 +962,7 @@ Item::set_image (const QImage &image)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QImage
|
QImage
|
||||||
Item::image () const
|
Item::image () const
|
||||||
{
|
{
|
||||||
if (m_image_str.empty ()) {
|
if (m_image_str.empty ()) {
|
||||||
|
|
@ -980,6 +981,29 @@ Item::image () const
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_PNG)
|
||||||
|
|
||||||
|
tl::PixelBuffer
|
||||||
|
Item::image_pixels () const
|
||||||
|
{
|
||||||
|
std::vector<unsigned char> data = tl::from_base64 (m_image_str.c_str ());
|
||||||
|
tl::InputStream stream (new tl::InputMemoryStream ((const char *) data.begin ().operator-> (), data.size ()));
|
||||||
|
return tl::PixelBuffer::read_png (stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Item::set_image (const tl::PixelBuffer &image)
|
||||||
|
{
|
||||||
|
tl::OutputMemoryStream mem;
|
||||||
|
{
|
||||||
|
tl::OutputStream stream (mem);
|
||||||
|
image.write_png (stream);
|
||||||
|
}
|
||||||
|
m_image_str = tl::to_base64 ((const unsigned char *) mem.data (), mem.size ());
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Item::has_image () const
|
Item::has_image () const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
#include "gsi.h"
|
#include "gsi.h"
|
||||||
#include "tlObject.h"
|
#include "tlObject.h"
|
||||||
#include "tlObjectCollection.h"
|
#include "tlObjectCollection.h"
|
||||||
|
#include "tlPixelBuffer.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
@ -945,7 +946,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return The image object or an empty image if no image is attached
|
* @return The image object or an empty image if no image is attached
|
||||||
*/
|
*/
|
||||||
const QImage image () const;
|
QImage image () const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the image for this item
|
* @brief Set the image for this item
|
||||||
|
|
@ -953,6 +954,18 @@ public:
|
||||||
void set_image (const QImage &image);
|
void set_image (const QImage &image);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_PNG)
|
||||||
|
/**
|
||||||
|
* @brief Gets the image as a tl::PixelBuffer object
|
||||||
|
*/
|
||||||
|
tl::PixelBuffer image_pixels () const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the image from a tl::PixelBuffer object
|
||||||
|
*/
|
||||||
|
void set_image (const tl::PixelBuffer &image);
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets a value indicating whether the item has an image
|
* @brief Gets a value indicating whether the item has an image
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -551,4 +551,50 @@ TEST(6)
|
||||||
EXPECT_EQ (db.variants ("c2")[5], c2e->id ());
|
EXPECT_EQ (db.variants ("c2")[5], c2e->id ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(7)
|
||||||
|
{
|
||||||
|
rdb::Database db;
|
||||||
|
rdb::Category *cath = db.create_category ("cath_name");
|
||||||
|
rdb::Cell *c1 = db.create_cell ("c1");
|
||||||
|
rdb::Item *i1 = db.create_item (c1->id (), cath->id ());
|
||||||
|
|
||||||
|
#if defined(HAVE_QT)
|
||||||
|
|
||||||
|
{
|
||||||
|
QImage img (16, 26, QImage::Format_RGB32);
|
||||||
|
for (int i = 0; i < img.height (); ++i) {
|
||||||
|
for (int j = 0; j < img.height (); ++j) {
|
||||||
|
img.scanLine (j) [i] = (i << 16) + j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i1->set_image (img);
|
||||||
|
|
||||||
|
QImage img2 = i1->image ();
|
||||||
|
|
||||||
|
EXPECT_EQ (img.width (), img2.width ());
|
||||||
|
EXPECT_EQ (img.height (), img2.height ());
|
||||||
|
EXPECT_EQ (tl::PixelBuffer::from_image (img) == tl::PixelBuffer::from_image (img2), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_PNG)
|
||||||
|
|
||||||
|
{
|
||||||
|
tl::PixelBuffer img (16, 26);
|
||||||
|
for (unsigned int i = 0; i < img.width (); ++i) {
|
||||||
|
for (unsigned int j = 0; j < img.height (); ++j) {
|
||||||
|
img.scan_line (j) [i] = (i << 16) + j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i1->set_image (img);
|
||||||
|
|
||||||
|
tl::PixelBuffer img2 = i1->image_pixels ();
|
||||||
|
|
||||||
|
EXPECT_EQ (img.width (), img2.width ());
|
||||||
|
EXPECT_EQ (img.height (), img2.height ());
|
||||||
|
EXPECT_EQ (img == img2, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
@ -7,8 +7,8 @@ TARGET = rdb_tests
|
||||||
include($$PWD/../../lib_ut.pri)
|
include($$PWD/../../lib_ut.pri)
|
||||||
|
|
||||||
SOURCES = \
|
SOURCES = \
|
||||||
rdb.cc \
|
rdbRVEReaderTests.cc \
|
||||||
rdbRVEReaderTests.cc
|
rdbTests.cc
|
||||||
|
|
||||||
INCLUDEPATH += $$RDB_INC $$TL_INC $$DB_INC $$GSI_INC
|
INCLUDEPATH += $$RDB_INC $$TL_INC $$DB_INC $$GSI_INC
|
||||||
DEPENDPATH += $$RDB_INC $$TL_INC $$DB_INC $$GSI_INC
|
DEPENDPATH += $$RDB_INC $$TL_INC $$DB_INC $$GSI_INC
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ SOURCES = \
|
||||||
tlLog.cc \
|
tlLog.cc \
|
||||||
tlObject.cc \
|
tlObject.cc \
|
||||||
tlProgress.cc \
|
tlProgress.cc \
|
||||||
|
tlPixelBuffer.cc \
|
||||||
tlResources.cc \
|
tlResources.cc \
|
||||||
tlScriptError.cc \
|
tlScriptError.cc \
|
||||||
tlSleep.cc \
|
tlSleep.cc \
|
||||||
|
|
@ -81,6 +82,7 @@ HEADERS = \
|
||||||
tlObject.h \
|
tlObject.h \
|
||||||
tlObjectCollection.h \
|
tlObjectCollection.h \
|
||||||
tlProgress.h \
|
tlProgress.h \
|
||||||
|
tlPixelBuffer.h \
|
||||||
tlResources.h \
|
tlResources.h \
|
||||||
tlReuseVector.h \
|
tlReuseVector.h \
|
||||||
tlScriptError.h \
|
tlScriptError.h \
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "layPixelBuffer.h"
|
#include "tlPixelBuffer.h"
|
||||||
#include "tlAssert.h"
|
#include "tlAssert.h"
|
||||||
#include "tlLog.h"
|
#include "tlLog.h"
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace lay
|
namespace tl
|
||||||
{
|
{
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------
|
||||||
|
|
@ -20,10 +20,10 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef HDR_layPixelBuffer
|
#ifndef HDR_tlPixelBuffer
|
||||||
#define HDR_layPixelBuffer
|
#define HDR_tlPixelBuffer
|
||||||
|
|
||||||
#include "laybasicCommon.h"
|
#include "tlCommon.h"
|
||||||
#include "tlColor.h"
|
#include "tlColor.h"
|
||||||
#include "tlCopyOnWrite.h"
|
#include "tlCopyOnWrite.h"
|
||||||
#include "tlStream.h"
|
#include "tlStream.h"
|
||||||
|
|
@ -36,13 +36,13 @@
|
||||||
# include <QImage>
|
# include <QImage>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace lay
|
namespace tl
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief An exception thrown when a PNG read error occurs
|
* @brief An exception thrown when a PNG read error occurs
|
||||||
*/
|
*/
|
||||||
class LAYBASIC_PUBLIC PixelBufferReadError
|
class TL_PUBLIC PixelBufferReadError
|
||||||
: public tl::Exception
|
: public tl::Exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -53,7 +53,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief An exception thrown when a PNG write error occurs
|
* @brief An exception thrown when a PNG write error occurs
|
||||||
*/
|
*/
|
||||||
class LAYBASIC_PUBLIC PixelBufferWriteError
|
class TL_PUBLIC PixelBufferWriteError
|
||||||
: public tl::Exception
|
: public tl::Exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -67,7 +67,7 @@ public:
|
||||||
* This class substitutes QImage in Qt-less applications.
|
* This class substitutes QImage in Qt-less applications.
|
||||||
* It provides 32bit RGBA pixels with the format used by tl::Color.
|
* It provides 32bit RGBA pixels with the format used by tl::Color.
|
||||||
*/
|
*/
|
||||||
class LAYBASIC_PUBLIC PixelBuffer
|
class TL_PUBLIC PixelBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
@ -329,7 +329,7 @@ private:
|
||||||
* This class substitutes QImage for monochrome images in Qt-less applications.
|
* This class substitutes QImage for monochrome images in Qt-less applications.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class LAYBASIC_PUBLIC BitmapBuffer
|
class TL_PUBLIC BitmapBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "layPixelBuffer.h"
|
#include "tlPixelBuffer.h"
|
||||||
|
|
||||||
#include "tlUnitTest.h"
|
#include "tlUnitTest.h"
|
||||||
#include "tlTimer.h"
|
#include "tlTimer.h"
|
||||||
|
|
@ -72,19 +72,19 @@ static bool compare_images_mono (const QImage &qimg, const std::string &au)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool compare_images (const lay::PixelBuffer &img, const lay::PixelBuffer &img2)
|
static bool compare_images (const tl::PixelBuffer &img, const tl::PixelBuffer &img2)
|
||||||
{
|
{
|
||||||
return img == img2;
|
return img == img2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool compare_images (const lay::BitmapBuffer &img, const lay::BitmapBuffer &img2)
|
static bool compare_images (const tl::BitmapBuffer &img, const tl::BitmapBuffer &img2)
|
||||||
{
|
{
|
||||||
return img == img2;
|
return img == img2;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(1)
|
TEST(1)
|
||||||
{
|
{
|
||||||
lay::PixelBuffer img (15, 25);
|
tl::PixelBuffer img (15, 25);
|
||||||
EXPECT_EQ (img.width (), 15);
|
EXPECT_EQ (img.width (), 15);
|
||||||
EXPECT_EQ (img.height (), 25);
|
EXPECT_EQ (img.height (), 25);
|
||||||
EXPECT_EQ (img.stride (), 15 * sizeof (tl::color_t));
|
EXPECT_EQ (img.stride (), 15 * sizeof (tl::color_t));
|
||||||
|
|
@ -96,7 +96,7 @@ TEST(1)
|
||||||
img.fill (0x112233);
|
img.fill (0x112233);
|
||||||
EXPECT_EQ (img.scan_line (5)[10], 0x112233);
|
EXPECT_EQ (img.scan_line (5)[10], 0x112233);
|
||||||
|
|
||||||
lay::PixelBuffer img2;
|
tl::PixelBuffer img2;
|
||||||
EXPECT_EQ (img2.transparent (), false);
|
EXPECT_EQ (img2.transparent (), false);
|
||||||
img2 = img;
|
img2 = img;
|
||||||
EXPECT_EQ (img2.transparent (), true);
|
EXPECT_EQ (img2.transparent (), true);
|
||||||
|
|
@ -121,7 +121,7 @@ TEST(1)
|
||||||
EXPECT_EQ (img.scan_line (5)[10], 0x332211);
|
EXPECT_EQ (img.scan_line (5)[10], 0x332211);
|
||||||
EXPECT_EQ (img2.scan_line (5)[10], 0x332211);
|
EXPECT_EQ (img2.scan_line (5)[10], 0x332211);
|
||||||
|
|
||||||
img2 = lay::PixelBuffer (10, 16);
|
img2 = tl::PixelBuffer (10, 16);
|
||||||
EXPECT_EQ (img.width (), 15);
|
EXPECT_EQ (img.width (), 15);
|
||||||
EXPECT_EQ (img.height (), 25);
|
EXPECT_EQ (img.height (), 25);
|
||||||
EXPECT_EQ (img2.width (), 10);
|
EXPECT_EQ (img2.width (), 10);
|
||||||
|
|
@ -138,7 +138,7 @@ TEST(1)
|
||||||
EXPECT_EQ (img.height (), 16);
|
EXPECT_EQ (img.height (), 16);
|
||||||
EXPECT_EQ (img.scan_line (5)[8], 0xff010203);
|
EXPECT_EQ (img.scan_line (5)[8], 0xff010203);
|
||||||
|
|
||||||
lay::PixelBuffer img3 (img);
|
tl::PixelBuffer img3 (img);
|
||||||
EXPECT_EQ (compare_images (img, img3), true);
|
EXPECT_EQ (compare_images (img, img3), true);
|
||||||
EXPECT_EQ (img3.width (), 10);
|
EXPECT_EQ (img3.width (), 10);
|
||||||
EXPECT_EQ (img3.height (), 16);
|
EXPECT_EQ (img3.height (), 16);
|
||||||
|
|
@ -153,25 +153,25 @@ TEST(1)
|
||||||
EXPECT_EQ (img.height (), 16);
|
EXPECT_EQ (img.height (), 16);
|
||||||
EXPECT_EQ (img.scan_line (5)[8], 0xff102030);
|
EXPECT_EQ (img.scan_line (5)[8], 0xff102030);
|
||||||
|
|
||||||
lay::PixelBuffer img4 (std::move (img));
|
tl::PixelBuffer img4 (std::move (img));
|
||||||
EXPECT_EQ (img4.width (), 10);
|
EXPECT_EQ (img4.width (), 10);
|
||||||
EXPECT_EQ (img4.height (), 16);
|
EXPECT_EQ (img4.height (), 16);
|
||||||
EXPECT_EQ (img4.scan_line (5)[8], 0xff102030);
|
EXPECT_EQ (img4.scan_line (5)[8], 0xff102030);
|
||||||
|
|
||||||
// other constructors
|
// other constructors
|
||||||
EXPECT_EQ (compare_images (lay::PixelBuffer (img4.width (), img4.height (), (const tl::color_t *) img4.data ()), img4), true);
|
EXPECT_EQ (compare_images (tl::PixelBuffer (img4.width (), img4.height (), (const tl::color_t *) img4.data ()), img4), true);
|
||||||
EXPECT_EQ (compare_images (lay::PixelBuffer (img4.width (), img4.height (), (const tl::color_t *) img4.data (), img4.stride ()), img4), true);
|
EXPECT_EQ (compare_images (tl::PixelBuffer (img4.width (), img4.height (), (const tl::color_t *) img4.data (), img4.stride ()), img4), true);
|
||||||
|
|
||||||
tl::color_t *dnew = new tl::color_t [ img4.width () * img4.height () * sizeof (tl::color_t) ];
|
tl::color_t *dnew = new tl::color_t [ img4.width () * img4.height () * sizeof (tl::color_t) ];
|
||||||
memcpy (dnew, (const tl::color_t *) img4.data (), img4.width () * img4.height () * sizeof (tl::color_t));
|
memcpy (dnew, (const tl::color_t *) img4.data (), img4.width () * img4.height () * sizeof (tl::color_t));
|
||||||
EXPECT_EQ (compare_images (lay::PixelBuffer (img4.width (), img4.height (), dnew), img4), true);
|
EXPECT_EQ (compare_images (tl::PixelBuffer (img4.width (), img4.height (), dnew), img4), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_QT)
|
#if defined(HAVE_QT)
|
||||||
|
|
||||||
TEST(2)
|
TEST(2)
|
||||||
{
|
{
|
||||||
lay::PixelBuffer img (227, 231);
|
tl::PixelBuffer img (227, 231);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < img.width (); ++i) {
|
for (unsigned int i = 0; i < img.width (); ++i) {
|
||||||
for (unsigned int j = 0; j < img.height (); ++j) {
|
for (unsigned int j = 0; j < img.height (); ++j) {
|
||||||
|
|
@ -192,13 +192,13 @@ TEST(2)
|
||||||
|
|
||||||
EXPECT_EQ (compare_images (qimg, au), true);
|
EXPECT_EQ (compare_images (qimg, au), true);
|
||||||
|
|
||||||
lay::PixelBuffer img_returned = lay::PixelBuffer::from_image (qimg);
|
tl::PixelBuffer img_returned = tl::PixelBuffer::from_image (qimg);
|
||||||
EXPECT_EQ (compare_images (img, img_returned), true);
|
EXPECT_EQ (compare_images (img, img_returned), true);
|
||||||
|
|
||||||
lay::PixelBuffer img_saved (img);
|
tl::PixelBuffer img_saved (img);
|
||||||
img.scan_line (52) [42] = 0xff000000;
|
img.scan_line (52) [42] = 0xff000000;
|
||||||
|
|
||||||
lay::PixelBuffer diff = img.diff (img_saved);
|
tl::PixelBuffer diff = img.diff (img_saved);
|
||||||
EXPECT_EQ (diff.transparent (), true);
|
EXPECT_EQ (diff.transparent (), true);
|
||||||
EXPECT_EQ (diff.to_image ().format () == QImage::Format_ARGB32, true);
|
EXPECT_EQ (diff.to_image ().format () == QImage::Format_ARGB32, true);
|
||||||
EXPECT_EQ (compare_images (img.to_image (), au), false);
|
EXPECT_EQ (compare_images (img.to_image (), au), false);
|
||||||
|
|
@ -237,14 +237,14 @@ TEST(2)
|
||||||
// libpng support
|
// libpng support
|
||||||
TEST(3)
|
TEST(3)
|
||||||
{
|
{
|
||||||
lay::PixelBuffer img;
|
tl::PixelBuffer img;
|
||||||
|
|
||||||
std::string in = tl::testsrc () + "/testdata/lay/png1.png"; // ARGB32
|
std::string in = tl::testsrc () + "/testdata/lay/png1.png"; // ARGB32
|
||||||
tl::info << "PNG file read (libpng) from " << in;
|
tl::info << "PNG file read (libpng) from " << in;
|
||||||
|
|
||||||
{
|
{
|
||||||
tl::InputStream stream (in);
|
tl::InputStream stream (in);
|
||||||
img = lay::PixelBuffer::read_png (stream);
|
img = tl::PixelBuffer::read_png (stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tmp = tmp_file ("test.png");
|
std::string tmp = tmp_file ("test.png");
|
||||||
|
|
@ -254,11 +254,11 @@ TEST(3)
|
||||||
}
|
}
|
||||||
tl::info << "PNG file written to " << tmp;
|
tl::info << "PNG file written to " << tmp;
|
||||||
|
|
||||||
lay::PixelBuffer img2;
|
tl::PixelBuffer img2;
|
||||||
|
|
||||||
{
|
{
|
||||||
tl::InputStream stream (tmp);
|
tl::InputStream stream (tmp);
|
||||||
img2 = lay::PixelBuffer::read_png (stream);
|
img2 = tl::PixelBuffer::read_png (stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tmp2 = tmp_file ("test2.png");
|
std::string tmp2 = tmp_file ("test2.png");
|
||||||
|
|
@ -279,14 +279,14 @@ TEST(3)
|
||||||
|
|
||||||
TEST(4)
|
TEST(4)
|
||||||
{
|
{
|
||||||
lay::PixelBuffer img;
|
tl::PixelBuffer img;
|
||||||
|
|
||||||
std::string in = tl::testsrc () + "/testdata/lay/png2.png"; // RGB32
|
std::string in = tl::testsrc () + "/testdata/lay/png2.png"; // RGB32
|
||||||
tl::info << "PNG file read (libpng) from " << in;
|
tl::info << "PNG file read (libpng) from " << in;
|
||||||
|
|
||||||
{
|
{
|
||||||
tl::InputStream stream (in);
|
tl::InputStream stream (in);
|
||||||
img = lay::PixelBuffer::read_png (stream);
|
img = tl::PixelBuffer::read_png (stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tmp = tmp_file ("test.png");
|
std::string tmp = tmp_file ("test.png");
|
||||||
|
|
@ -296,11 +296,11 @@ TEST(4)
|
||||||
}
|
}
|
||||||
tl::info << "PNG file written to " << tmp;
|
tl::info << "PNG file written to " << tmp;
|
||||||
|
|
||||||
lay::PixelBuffer img2;
|
tl::PixelBuffer img2;
|
||||||
|
|
||||||
{
|
{
|
||||||
tl::InputStream stream (tmp);
|
tl::InputStream stream (tmp);
|
||||||
img2 = lay::PixelBuffer::read_png (stream);
|
img2 = tl::PixelBuffer::read_png (stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tmp2 = tmp_file ("test2.png");
|
std::string tmp2 = tmp_file ("test2.png");
|
||||||
|
|
@ -321,14 +321,14 @@ TEST(4)
|
||||||
|
|
||||||
TEST(5)
|
TEST(5)
|
||||||
{
|
{
|
||||||
lay::PixelBuffer img;
|
tl::PixelBuffer img;
|
||||||
|
|
||||||
std::string in = tl::testsrc () + "/testdata/lay/png3.png"; // GA
|
std::string in = tl::testsrc () + "/testdata/lay/png3.png"; // GA
|
||||||
tl::info << "PNG file read (libpng) from " << in;
|
tl::info << "PNG file read (libpng) from " << in;
|
||||||
|
|
||||||
{
|
{
|
||||||
tl::InputStream stream (in);
|
tl::InputStream stream (in);
|
||||||
img = lay::PixelBuffer::read_png (stream);
|
img = tl::PixelBuffer::read_png (stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tmp = tmp_file ("test.png");
|
std::string tmp = tmp_file ("test.png");
|
||||||
|
|
@ -338,11 +338,11 @@ TEST(5)
|
||||||
}
|
}
|
||||||
tl::info << "PNG file written to " << tmp;
|
tl::info << "PNG file written to " << tmp;
|
||||||
|
|
||||||
lay::PixelBuffer img2;
|
tl::PixelBuffer img2;
|
||||||
|
|
||||||
{
|
{
|
||||||
tl::InputStream stream (tmp);
|
tl::InputStream stream (tmp);
|
||||||
img2 = lay::PixelBuffer::read_png (stream);
|
img2 = tl::PixelBuffer::read_png (stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tmp2 = tmp_file ("test2.png");
|
std::string tmp2 = tmp_file ("test2.png");
|
||||||
|
|
@ -363,14 +363,14 @@ TEST(5)
|
||||||
|
|
||||||
TEST(6)
|
TEST(6)
|
||||||
{
|
{
|
||||||
lay::PixelBuffer img;
|
tl::PixelBuffer img;
|
||||||
|
|
||||||
std::string in = tl::testsrc () + "/testdata/lay/png4.png"; // G
|
std::string in = tl::testsrc () + "/testdata/lay/png4.png"; // G
|
||||||
tl::info << "PNG file read (libpng) from " << in;
|
tl::info << "PNG file read (libpng) from " << in;
|
||||||
|
|
||||||
{
|
{
|
||||||
tl::InputStream stream (in);
|
tl::InputStream stream (in);
|
||||||
img = lay::PixelBuffer::read_png (stream);
|
img = tl::PixelBuffer::read_png (stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tmp = tmp_file ("test.png");
|
std::string tmp = tmp_file ("test.png");
|
||||||
|
|
@ -380,11 +380,11 @@ TEST(6)
|
||||||
}
|
}
|
||||||
tl::info << "PNG file written to " << tmp;
|
tl::info << "PNG file written to " << tmp;
|
||||||
|
|
||||||
lay::PixelBuffer img2;
|
tl::PixelBuffer img2;
|
||||||
|
|
||||||
{
|
{
|
||||||
tl::InputStream stream (tmp);
|
tl::InputStream stream (tmp);
|
||||||
img2 = lay::PixelBuffer::read_png (stream);
|
img2 = tl::PixelBuffer::read_png (stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tmp2 = tmp_file ("test2.png");
|
std::string tmp2 = tmp_file ("test2.png");
|
||||||
|
|
@ -408,13 +408,13 @@ TEST(6)
|
||||||
TEST(7)
|
TEST(7)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
tl::SelfTimer timer ("Run time - lay::Image copy, no write (should be very fast)");
|
tl::SelfTimer timer ("Run time - tl::Image copy, no write (should be very fast)");
|
||||||
|
|
||||||
lay::PixelBuffer img (1000, 1000);
|
tl::PixelBuffer img (1000, 1000);
|
||||||
img.fill (0x112233);
|
img.fill (0x112233);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < 5000; ++i) {
|
for (unsigned int i = 0; i < 5000; ++i) {
|
||||||
lay::PixelBuffer img2 (img);
|
tl::PixelBuffer img2 (img);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -422,7 +422,7 @@ TEST(7)
|
||||||
{
|
{
|
||||||
tl::SelfTimer timer ("Run time - QImage copy, no write (should be very fast)");
|
tl::SelfTimer timer ("Run time - QImage copy, no write (should be very fast)");
|
||||||
|
|
||||||
lay::PixelBuffer img (1000, 1000);
|
tl::PixelBuffer img (1000, 1000);
|
||||||
img.fill (0x112233);
|
img.fill (0x112233);
|
||||||
QImage qimg (img.to_image ());
|
QImage qimg (img.to_image ());
|
||||||
|
|
||||||
|
|
@ -433,22 +433,22 @@ TEST(7)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
tl::SelfTimer timer ("Run time - lay::Image copy on write");
|
tl::SelfTimer timer ("Run time - tl::Image copy on write");
|
||||||
|
|
||||||
lay::PixelBuffer img (1000, 1000);
|
tl::PixelBuffer img (1000, 1000);
|
||||||
img.fill (0x112233);
|
img.fill (0x112233);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < 5000; ++i) {
|
for (unsigned int i = 0; i < 5000; ++i) {
|
||||||
lay::PixelBuffer img2 (img);
|
tl::PixelBuffer img2 (img);
|
||||||
img2.scan_line (100) [7] = 0;
|
img2.scan_line (100) [7] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_QT)
|
#if defined(HAVE_QT)
|
||||||
{
|
{
|
||||||
tl::SelfTimer timer ("Run time - QImage copy on write (should not be much less than lay::Image copy on write)");
|
tl::SelfTimer timer ("Run time - QImage copy on write (should not be much less than tl::Image copy on write)");
|
||||||
|
|
||||||
lay::PixelBuffer img (1000, 1000);
|
tl::PixelBuffer img (1000, 1000);
|
||||||
img.fill (0x112233);
|
img.fill (0x112233);
|
||||||
QImage qimg (img.to_image ());
|
QImage qimg (img.to_image ());
|
||||||
|
|
||||||
|
|
@ -461,7 +461,7 @@ TEST(7)
|
||||||
{
|
{
|
||||||
tl::SelfTimer timer ("Run time - direct QImage paint");
|
tl::SelfTimer timer ("Run time - direct QImage paint");
|
||||||
|
|
||||||
lay::PixelBuffer img (1000, 1000);
|
tl::PixelBuffer img (1000, 1000);
|
||||||
img.fill (0x112233);
|
img.fill (0x112233);
|
||||||
QImage qimg (img.to_image ());
|
QImage qimg (img.to_image ());
|
||||||
QImage qrec (img.to_image ());
|
QImage qrec (img.to_image ());
|
||||||
|
|
@ -474,9 +474,9 @@ TEST(7)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
tl::SelfTimer timer ("Run time - lay::Image paint (should not be much more than direct QImage paint)");
|
tl::SelfTimer timer ("Run time - tl::Image paint (should not be much more than direct QImage paint)");
|
||||||
|
|
||||||
lay::PixelBuffer img (1000, 1000);
|
tl::PixelBuffer img (1000, 1000);
|
||||||
img.fill (0x112233);
|
img.fill (0x112233);
|
||||||
QImage qrec (img.to_image ());
|
QImage qrec (img.to_image ());
|
||||||
qrec.fill (0);
|
qrec.fill (0);
|
||||||
|
|
@ -494,7 +494,7 @@ TEST(7)
|
||||||
|
|
||||||
TEST(11)
|
TEST(11)
|
||||||
{
|
{
|
||||||
lay::BitmapBuffer img (15, 25);
|
tl::BitmapBuffer img (15, 25);
|
||||||
EXPECT_EQ (img.width (), 15);
|
EXPECT_EQ (img.width (), 15);
|
||||||
EXPECT_EQ (img.height (), 25);
|
EXPECT_EQ (img.height (), 25);
|
||||||
EXPECT_EQ (img.stride (), 4);
|
EXPECT_EQ (img.stride (), 4);
|
||||||
|
|
@ -502,7 +502,7 @@ TEST(11)
|
||||||
img.fill (true);
|
img.fill (true);
|
||||||
EXPECT_EQ (img.scan_line (5)[1], 0xff);
|
EXPECT_EQ (img.scan_line (5)[1], 0xff);
|
||||||
|
|
||||||
lay::BitmapBuffer img2;
|
tl::BitmapBuffer img2;
|
||||||
img2 = img;
|
img2 = img;
|
||||||
EXPECT_EQ (img2.width (), 15);
|
EXPECT_EQ (img2.width (), 15);
|
||||||
EXPECT_EQ (img2.height (), 25);
|
EXPECT_EQ (img2.height (), 25);
|
||||||
|
|
@ -523,7 +523,7 @@ TEST(11)
|
||||||
EXPECT_EQ (img.scan_line (5)[1], 0);
|
EXPECT_EQ (img.scan_line (5)[1], 0);
|
||||||
EXPECT_EQ (img2.scan_line (5)[1], 0);
|
EXPECT_EQ (img2.scan_line (5)[1], 0);
|
||||||
|
|
||||||
img2 = lay::BitmapBuffer (10, 16);
|
img2 = tl::BitmapBuffer (10, 16);
|
||||||
EXPECT_EQ (img.width (), 15);
|
EXPECT_EQ (img.width (), 15);
|
||||||
EXPECT_EQ (img.height (), 25);
|
EXPECT_EQ (img.height (), 25);
|
||||||
EXPECT_EQ (img2.width (), 10);
|
EXPECT_EQ (img2.width (), 10);
|
||||||
|
|
@ -540,7 +540,7 @@ TEST(11)
|
||||||
EXPECT_EQ (img.height (), 16);
|
EXPECT_EQ (img.height (), 16);
|
||||||
EXPECT_EQ (img.scan_line (5)[0], 0xff);
|
EXPECT_EQ (img.scan_line (5)[0], 0xff);
|
||||||
|
|
||||||
lay::BitmapBuffer img3 (img);
|
tl::BitmapBuffer img3 (img);
|
||||||
EXPECT_EQ (compare_images (img, img3), true);
|
EXPECT_EQ (compare_images (img, img3), true);
|
||||||
EXPECT_EQ (img3.width (), 10);
|
EXPECT_EQ (img3.width (), 10);
|
||||||
EXPECT_EQ (img3.height (), 16);
|
EXPECT_EQ (img3.height (), 16);
|
||||||
|
|
@ -555,25 +555,25 @@ TEST(11)
|
||||||
EXPECT_EQ (img.height (), 16);
|
EXPECT_EQ (img.height (), 16);
|
||||||
EXPECT_EQ (img.scan_line (5)[1], 0);
|
EXPECT_EQ (img.scan_line (5)[1], 0);
|
||||||
|
|
||||||
lay::BitmapBuffer img4 (std::move (img));
|
tl::BitmapBuffer img4 (std::move (img));
|
||||||
EXPECT_EQ (img4.width (), 10);
|
EXPECT_EQ (img4.width (), 10);
|
||||||
EXPECT_EQ (img4.height (), 16);
|
EXPECT_EQ (img4.height (), 16);
|
||||||
EXPECT_EQ (img4.scan_line (5)[1], 0);
|
EXPECT_EQ (img4.scan_line (5)[1], 0);
|
||||||
|
|
||||||
// other constructors
|
// other constructors
|
||||||
EXPECT_EQ (compare_images (lay::BitmapBuffer (img4.width (), img4.height (), (const uint8_t *) img4.data ()), img4), true);
|
EXPECT_EQ (compare_images (tl::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);
|
EXPECT_EQ (compare_images (tl::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) ];
|
uint8_t *dnew = new uint8_t [ img4.width () * img4.height () * sizeof (uint8_t) ];
|
||||||
memcpy (dnew, (const uint8_t *) img4.data (), img4.stride () * img4.height ());
|
memcpy (dnew, (const uint8_t *) img4.data (), img4.stride () * img4.height ());
|
||||||
EXPECT_EQ (compare_images (lay::BitmapBuffer (img4.width (), img4.height (), dnew), img4), true);
|
EXPECT_EQ (compare_images (tl::BitmapBuffer (img4.width (), img4.height (), dnew), img4), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_QT)
|
#if defined(HAVE_QT)
|
||||||
|
|
||||||
TEST(12)
|
TEST(12)
|
||||||
{
|
{
|
||||||
lay::BitmapBuffer img (227, 231);
|
tl::BitmapBuffer img (227, 231);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < img.stride (); ++i) {
|
for (unsigned int i = 0; i < img.stride (); ++i) {
|
||||||
for (unsigned int j = 0; j < img.height (); ++j) {
|
for (unsigned int j = 0; j < img.height (); ++j) {
|
||||||
|
|
@ -593,7 +593,7 @@ TEST(12)
|
||||||
|
|
||||||
EXPECT_EQ (compare_images_mono (qimg, au), true);
|
EXPECT_EQ (compare_images_mono (qimg, au), true);
|
||||||
|
|
||||||
lay::BitmapBuffer img_returned = lay::BitmapBuffer::from_image (qimg);
|
tl::BitmapBuffer img_returned = tl::BitmapBuffer::from_image (qimg);
|
||||||
EXPECT_EQ (compare_images (img, img_returned), true);
|
EXPECT_EQ (compare_images (img, img_returned), true);
|
||||||
|
|
||||||
qimg = img.to_image_copy ();
|
qimg = img.to_image_copy ();
|
||||||
|
|
@ -613,14 +613,14 @@ TEST(12)
|
||||||
// libpng support
|
// libpng support
|
||||||
TEST(13)
|
TEST(13)
|
||||||
{
|
{
|
||||||
lay::BitmapBuffer img;
|
tl::BitmapBuffer img;
|
||||||
|
|
||||||
std::string in = tl::testsrc () + "/testdata/lay/au_mono.png";
|
std::string in = tl::testsrc () + "/testdata/lay/au_mono.png";
|
||||||
tl::info << "PNG file read (libpng) from " << in;
|
tl::info << "PNG file read (libpng) from " << in;
|
||||||
|
|
||||||
{
|
{
|
||||||
tl::InputStream stream (in);
|
tl::InputStream stream (in);
|
||||||
img = lay::BitmapBuffer::read_png (stream);
|
img = tl::BitmapBuffer::read_png (stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tmp = tmp_file ("test.png");
|
std::string tmp = tmp_file ("test.png");
|
||||||
|
|
@ -630,11 +630,11 @@ TEST(13)
|
||||||
}
|
}
|
||||||
tl::info << "PNG file written to " << tmp;
|
tl::info << "PNG file written to " << tmp;
|
||||||
|
|
||||||
lay::BitmapBuffer img2;
|
tl::BitmapBuffer img2;
|
||||||
|
|
||||||
{
|
{
|
||||||
tl::InputStream stream (tmp);
|
tl::InputStream stream (tmp);
|
||||||
img2 = lay::BitmapBuffer::read_png (stream);
|
img2 = tl::BitmapBuffer::read_png (stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tmp2 = tmp_file ("test2.png");
|
std::string tmp2 = tmp_file ("test2.png");
|
||||||
|
|
@ -29,6 +29,7 @@ SOURCES = \
|
||||||
tlLongIntTests.cc \
|
tlLongIntTests.cc \
|
||||||
tlMathTests.cc \
|
tlMathTests.cc \
|
||||||
tlObjectTests.cc \
|
tlObjectTests.cc \
|
||||||
|
tlPixelBufferTests.cc \
|
||||||
tlResourcesTests.cc \
|
tlResourcesTests.cc \
|
||||||
tlReuseVectorTests.cc \
|
tlReuseVectorTests.cc \
|
||||||
tlStableVectorTests.cc \
|
tlStableVectorTests.cc \
|
||||||
|
|
|
||||||
|
|
@ -430,6 +430,25 @@ class RDB_TestClass < TestBase
|
||||||
item.image_str=is
|
item.image_str=is
|
||||||
assert_equal(item.image_str, is)
|
assert_equal(item.image_str, is)
|
||||||
assert_equal(item.has_image?, true)
|
assert_equal(item.has_image?, true)
|
||||||
|
|
||||||
|
if item.respond_to?(:image_pixels)
|
||||||
|
px=item.image_pixels
|
||||||
|
assert_equal(px.width, 42)
|
||||||
|
assert_equal(px.height, 52)
|
||||||
|
item.image = px
|
||||||
|
px2=item.image_pixels
|
||||||
|
assert_equal(px == px2, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
if item.respond_to?(:image)
|
||||||
|
px=item.image
|
||||||
|
assert_equal(px.width, 42)
|
||||||
|
assert_equal(px.height, 52)
|
||||||
|
item.image = px
|
||||||
|
px2=item.image
|
||||||
|
assert_equal(px2.width, 42)
|
||||||
|
assert_equal(px2.height, 52)
|
||||||
|
end
|
||||||
|
|
||||||
vs = RBA::RdbItemValue.new("a string")
|
vs = RBA::RdbItemValue.new("a string")
|
||||||
vs2 = RBA::RdbItemValue.new("a string (ii)")
|
vs2 = RBA::RdbItemValue.new("a string (ii)")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue