37#ifndef MWAW_PICT_BITMAP
38# define MWAW_PICT_BITMAP
64 size_t const numElements=size_t(
m_size[0])*size_t(
m_size[1]);
65 m_data =
new T[numElements];
66 std::uninitialized_fill_n(
m_data, numElements, T());
77 return (
m_data !=
nullptr);
84 if (diff)
return diff;
86 if (!orig.
m_data)
return -1;
110 T
const &
get(
int i,
int j)
const
125 void set(
int i,
int j, T
const &v)
128 MWAW_DEBUG_MSG((
"MWAWPictBitmapContainer::set: call with bad coordinate %d %d\n", i, j));
139 MWAW_DEBUG_MSG((
"MWAWPictBitmapContainer::setRow: call with bad coordinate %d\n", j));
150 MWAW_DEBUG_MSG((
"MWAWPictBitmapContainer::setColumn: call with bad coordinate %d\n", i));
180 int diff =
m_size.cmpY(orig.m_size);
181 if (diff)
return diff;
182 if (!
m_data)
return orig.m_data ? 1 : 0;
183 if (!orig.m_data)
return -1;
185 if (
m_data[i] == orig.m_data[i])
continue;
186 return m_data[i] ? 1 : -1;
192 void setRowPacked(
int j,
unsigned char const *val,
unsigned char const *end)
194 if (
m_data ==
nullptr || j<0 || j >=
m_size[1] || val >= end) {
195 MWAW_DEBUG_MSG((
"MWAWPictBitmapContainerBool::setRowPacked: call with bad coordinate %d\n", j));
199 unsigned char v = (val < end) ? *(val++) : 0;
200 unsigned char mask = 0x80;
201 for (
int p = 0; p < 8 && i <
m_size[0]; i++, p++, ind++) {
202 m_data[ind] = ((v&mask) != 0);
203 mask =
static_cast<unsigned char>(mask >> 1);
229 if (!
valid())
return false;
231 librevenge::RVNGBinaryData data;
250 if (diff)
return diff;
255 if (diff)
return (diff < 0) ? -1 : 1;
286 if (diff)
return diff;
289 return m_data.cmp(aPict.m_data);
318 return m_data.numColumns();
321 bool get(
int i,
int j)
const
331 void set(
int i,
int j,
bool v)
341 void setRowPacked(
int j,
unsigned char const *val,
unsigned char const *end)
343 m_data.setRowPacked(j, val, end);
376 if (diff)
return diff;
379 diff=int(
m_colors.size())-int(aPict.m_colors.size());
380 if (diff)
return (diff < 0) ? -1 : 1;
381 for (
size_t c=0; c <
m_colors.size(); c++) {
382 if (
m_colors[c] < aPict.m_colors[c])
384 if (
m_colors[c] > aPict.m_colors[c])
387 return m_data.cmp(aPict.m_data);
419 return m_data.numColumns();
422 int get(
int i,
int j)
const
433 void set(
int i,
int j,
int v)
438 template <
class U>
void setRow(
int j, U
const *val)
461 bool createFileData(librevenge::RVNGBinaryData &result)
const final;
490 if (diff)
return diff;
493 return m_data.cmp(aPict.m_data);
525 return m_data.numColumns();
556 bool createFileData(librevenge::RVNGBinaryData &result)
const final;
void setColumn(int i, bool const *val)
sets all cell contents of a column
Definition MWAWPictBitmap.hxx:346
void setRowPacked(int j, unsigned char const *val, unsigned char const *end)
sets all cell contents of a row given packed m_data
Definition MWAWPictBitmap.hxx:341
void set(int i, int j, bool v)
sets a cell contents
Definition MWAWPictBitmap.hxx:331
MWAWVec2i const & size() const
the picture size
Definition MWAWPictBitmap.hxx:306
int numRows() const
the number of rows
Definition MWAWPictBitmap.hxx:311
bool get(int i, int j) const
returns a cell content
Definition MWAWPictBitmap.hxx:321
bool const * getRow(int j) const
returns the cells content of a row
Definition MWAWPictBitmap.hxx:326
SubType getSubType() const final
returns the picture subtype
Definition MWAWPictBitmap.hxx:276
MWAWPictBitmapBW(MWAWVec2i const &sz)
the constructor
Definition MWAWPictBitmap.hxx:299
int cmp(MWAWPict const &a) const final
a virtual function used to obtain a strict order, must be redefined in the subs class
Definition MWAWPictBitmap.hxx:283
int numColumns() const
the number of columns
Definition MWAWPictBitmap.hxx:316
MWAWColor getAverageColor() const final
returns the average color
Definition MWAWPictBitmap.cxx:514
bool createFileData(librevenge::RVNGBinaryData &result) const final
function which creates the result file
Definition MWAWPictBitmap.cxx:505
MWAWPictBitmapContainerBool m_data
the data
Definition MWAWPictBitmap.hxx:358
void setRow(int j, bool const *val)
sets all cell contents of a row
Definition MWAWPictBitmap.hxx:336
bool valid() const final
returns true if the picture is valid
Definition MWAWPictBitmap.hxx:293
SubType getSubType() const final
return the picture subtype
Definition MWAWPictBitmap.hxx:480
void set(int i, int j, MWAWColor const &v)
sets a cell contents
Definition MWAWPictBitmap.hxx:539
bool m_hasAlpha
true if the bitmap has alpha color
Definition MWAWPictBitmap.hxx:562
int cmp(MWAWPict const &a) const final
a virtual function used to obtain a strict order, must be redefined in the subs class
Definition MWAWPictBitmap.hxx:487
void setColumn(int i, MWAWColor const *val)
sets all cell contents of a column
Definition MWAWPictBitmap.hxx:549
MWAWVec2i const & size() const
the picture size
Definition MWAWPictBitmap.hxx:513
bool valid() const final
returns true if the picture is valid
Definition MWAWPictBitmap.hxx:497
MWAWPictBitmapColor(MWAWVec2i const &sz, bool useAlphaChannel=false)
the constructor
Definition MWAWPictBitmap.hxx:505
int numColumns() const
the number of columns
Definition MWAWPictBitmap.hxx:523
MWAWPictBitmapContainer< MWAWColor > m_data
the data
Definition MWAWPictBitmap.hxx:559
int numRows() const
the number of rows
Definition MWAWPictBitmap.hxx:518
void setRow(int j, MWAWColor const *val)
sets all cell contents of a row
Definition MWAWPictBitmap.hxx:544
MWAWColor get(int i, int j) const
returns a cell content
Definition MWAWPictBitmap.hxx:528
MWAWColor const * getRow(int j) const
returns the cells content of a row
Definition MWAWPictBitmap.hxx:533
a bool container with a function to put packed row
Definition MWAWPictBitmap.hxx:168
~MWAWPictBitmapContainerBool() final
destructor
Definition MWAWPictBitmap.cxx:494
int cmp(MWAWPictBitmapContainerBool const &orig) const
a comparison operator
Definition MWAWPictBitmap.hxx:178
MWAWPictBitmapContainerBool(MWAWVec2i const &sz)
constructor
Definition MWAWPictBitmap.hxx:171
void setRowPacked(int j, unsigned char const *val, unsigned char const *end)
allows to use packed m_data
Definition MWAWPictBitmap.hxx:192
a template class to store a 2D array of m_data
Definition MWAWPictBitmap.hxx:56
T * m_data
the m_data placed by row ie. d_00, d_10, ... , d_{X-1}0, ..
Definition MWAWPictBitmap.hxx:163
MWAWPictBitmapContainer(MWAWPictBitmapContainer const &orig)=delete
void set(int i, int j, T const &v)
sets a cell m_data
Definition MWAWPictBitmap.hxx:125
int numRows() const
gets the number of row
Definition MWAWPictBitmap.hxx:99
MWAWPictBitmapContainer(MWAWVec2i const &sz)
constructor given size
Definition MWAWPictBitmap.hxx:59
void setColumn(int i, U const *val)
sets a column of m_data
Definition MWAWPictBitmap.hxx:147
MWAWVec2i m_size
the size
Definition MWAWPictBitmap.hxx:161
void setRow(int j, U const *val)
sets a line of m_data
Definition MWAWPictBitmap.hxx:136
MWAWPictBitmapContainer & operator=(MWAWPictBitmapContainer const &orig)=delete
bool ok() const
returns ok, if the m_data is allocated
Definition MWAWPictBitmap.hxx:75
virtual ~MWAWPictBitmapContainer()
destructor
Definition MWAWPictBitmap.hxx:69
T const * getRow(int j) const
accessor of a row m_data
Definition MWAWPictBitmap.hxx:117
int cmp(MWAWPictBitmapContainer< T > const &orig) const
a comparison operator
Definition MWAWPictBitmap.hxx:81
MWAWVec2i const & size() const
return the array size
Definition MWAWPictBitmap.hxx:94
T const & get(int i, int j) const
accessor of a cell m_data
Definition MWAWPictBitmap.hxx:110
int numColumns() const
gets the number of column
Definition MWAWPictBitmap.hxx:104
MWAWPictBitmapIndexed(MWAWVec2i const &sz)
the constructor
Definition MWAWPictBitmap.hxx:399
void setColumn(int i, U const *val)
sets all cell contents of a column
Definition MWAWPictBitmap.hxx:443
MWAWVec2i const & size() const
the picture size
Definition MWAWPictBitmap.hxx:407
void setColors(std::vector< MWAWColor > const &cols)
sets the array of indexed colors
Definition MWAWPictBitmap.hxx:454
void setRow(int j, U const *val)
sets all cell contents of a row
Definition MWAWPictBitmap.hxx:438
int get(int i, int j) const
returns a cell content
Definition MWAWPictBitmap.hxx:422
std::vector< MWAWColor > m_colors
the colors
Definition MWAWPictBitmap.hxx:466
std::vector< MWAWColor > const & getColors() const
returns the array of indexed colors
Definition MWAWPictBitmap.hxx:449
int const * getRow(int j) const
returns the cells content of a row
Definition MWAWPictBitmap.hxx:427
SubType getSubType() const final
return the picture subtype
Definition MWAWPictBitmap.hxx:366
MWAWPictBitmapContainer< int > m_data
the m_data
Definition MWAWPictBitmap.hxx:464
int numRows() const
the number of rows
Definition MWAWPictBitmap.hxx:412
int cmp(MWAWPict const &a) const final
a virtual function used to obtain a strict order, must be redefined in the subs class
Definition MWAWPictBitmap.hxx:373
bool valid() const final
returns true if the picture is valid
Definition MWAWPictBitmap.hxx:391
int numColumns() const
the number of columns
Definition MWAWPictBitmap.hxx:417
void set(int i, int j, int v)
sets a cell contents
Definition MWAWPictBitmap.hxx:433
virtual MWAWColor getAverageColor() const =0
returns the average color
SubType
the picture subtype: blackwhite, indexed, color
Definition MWAWPictBitmap.hxx:217
@ BW
Definition MWAWPictBitmap.hxx:217
@ Color
Definition MWAWPictBitmap.hxx:217
@ Indexed
Definition MWAWPictBitmap.hxx:217
MWAWPictBitmap(MWAWVec2i const &sz)
protected constructor: use check to construct a picture
Definition MWAWPictBitmap.hxx:265
virtual SubType getSubType() const =0
returns the picture subtype
Type getType() const override
returns the picture type
Definition MWAWPictBitmap.hxx:219
virtual bool createFileData(librevenge::RVNGBinaryData &result) const =0
abstract function which creates the result file
~MWAWPictBitmap() override
destructor
Definition MWAWPictBitmap.cxx:498
int cmp(MWAWPict const &a) const override
a virtual function used to obtain a strict order, must be redefined in the subs class
Definition MWAWPictBitmap.hxx:247
bool getBinary(MWAWEmbeddedObject &picture) const override
returns the final picture
Definition MWAWPictBitmap.hxx:227
virtual bool valid() const
returns true if the picture is valid
Definition MWAWPictBitmap.hxx:238
MWAWPict()
protected constructor must not be called directly
Definition MWAWPict.hxx:143
Type
the different picture types:
Definition MWAWPict.hxx:63
@ Bitmap
Definition MWAWPict.hxx:63
virtual int cmp(MWAWPict const &a) const
a virtual function used to obtain a strict order, must be redefined in the subs class
Definition MWAWPict.hxx:101
void setBdBox(MWAWBox2f const &box)
sets the bdbox of the picture
Definition MWAWPict.hxx:84
Definition libmwaw_internal.hxx:148
MWAWVec2< int > MWAWVec2i
MWAWVec2 of int.
Definition libmwaw_internal.hxx:838
MWAWBox2< float > MWAWBox2f
MWAWBox2 of float.
Definition libmwaw_internal.hxx:1193
MWAWVec2< float > MWAWVec2f
MWAWVec2 of float.
Definition libmwaw_internal.hxx:842
#define MWAW_DEBUG_MSG(M)
Definition libmwaw_internal.hxx:129
Definition MWAWDocument.hxx:57
the class to store a color
Definition libmwaw_internal.hxx:192
small class use to define a embedded object
Definition libmwaw_internal.hxx:467