34#ifndef VP_IMAGE_OPERATOR_H
35#define VP_IMAGE_OPERATOR_H
41 if (I.bitmap ==
nullptr) {
45 unsigned int i_height = I.getHeight();
46 unsigned int i_width = I.getWidth();
47 for (
unsigned int i = 0; i < i_height; ++i) {
48 for (
unsigned int j = 0; j < (i_width - 1); ++j) {
53 s << I[i][i_width - 1];
56 if (i < (i_height - 1)) {
66 if (I.bitmap ==
nullptr) {
70 std::ios_base::fmtflags original_flags = s.flags();
71 const unsigned int magic_3 = 3;
73 unsigned int i_height = I.getHeight();
74 unsigned int i_width = I.getWidth();
75 for (
unsigned int i = 0; i < i_height; ++i) {
76 for (
unsigned int j = 0; j < (i_width - 1); ++j) {
77 s << std::setw(magic_3) << static_cast<unsigned>(I[i][j]) <<
" ";
81 s << std::setw(magic_3) << static_cast<unsigned>(I[i][I.getWidth() - 1]);
84 if (i < (i_height - 1)) {
89 s.flags(original_flags);
95 if (I.bitmap ==
nullptr) {
99 std::ios_base::fmtflags original_flags = s.flags();
100 const unsigned int magic_4 = 4;
102 unsigned int i_height = I.getHeight();
103 unsigned int i_width = I.getWidth();
104 for (
unsigned int i = 0; i < i_height; ++i) {
105 for (
unsigned int j = 0; j < (i_width - 1); ++j) {
106 s << std::setw(magic_4) << static_cast<int>(I[i][j]) <<
" ";
110 s << std::setw(magic_4) << static_cast<int>(I[i][i_width - 1]);
113 if (i < (i_height - 1)) {
118 s.flags(original_flags);
124 if (I.bitmap ==
nullptr) {
128 std::ios_base::fmtflags original_flags = s.flags();
129 const unsigned int magic_9 = 9;
130 s.precision(magic_9);
132 unsigned int i_height = I.getHeight();
133 unsigned int i_width = I.getWidth();
134 for (
unsigned int i = 0; i < i_height; ++i) {
135 for (
unsigned int j = 0; j < (i_width - 1); ++j) {
140 s << I[i][i_width - 1];
143 if (i < (i_height - 1)) {
148 s.flags(original_flags);
154 if (I.bitmap ==
nullptr) {
158 std::ios_base::fmtflags original_flags = s.flags();
159 const unsigned int magic_17 = 17;
160 s.precision(magic_17);
162 unsigned int i_height = I.getHeight();
163 unsigned int i_width = I.getWidth();
164 for (
unsigned int i = 0; i < i_height; ++i) {
165 for (
unsigned int j = 0; j < (i_width - 1); ++j) {
170 s << I[i][i_width - 1];
173 if (i < (i_height - 1)) {
178 s.flags(original_flags);
193 if ((height != other.height) || (width != other.width)) {
195 "Error in vpImage::operator=() where the display is initialised but the image size is different"));
198 resize(other.height, other.width);
199 memcpy(
static_cast<void *
>(
bitmap),
static_cast<void *
>(other.
bitmap), other.npixels *
sizeof(Type));
204#if ((__cplusplus >= 201103L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L)))
215 if (row !=
nullptr) {
219 if (
bitmap !=
nullptr && hasOwnership) {
225 if ((height != other.height) || (width != other.width)) {
227 "Error in vpImage::operator=(&) where the display is initialised but the image size is different"));
230 if (other.display !=
nullptr) {
232 "Error in vpImage::operator=(&&) where the display of the image to move is initialised"));
234 height = other.height;
236 npixels = other.npixels;
237 hasOwnership = other.hasOwnership;
239 other.bitmap =
nullptr;
240 other.display =
nullptr;
245 other.hasOwnership =
false;
259 for (
unsigned int i = 0; i < npixels; ++i) {
273 if (this->width != I.getWidth()) {
276 if (this->height != I.getHeight()) {
284 for (
unsigned int i = 0; i < npixels; ++i) {
285 if (
bitmap[i] != I.bitmap[i]) {
error that can be emitted by ViSP classes.
@ dimensionError
Bad dimension.
vpImage< Type > & operator=(const vpImage< Type > &other)
Copy operator.
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
friend std::ostream & operator<<(std::ostream &s, const vpImage< Type > &I)
bool operator==(const vpImage< Type > &I) const
vpImage< Type > operator-(const vpImage< Type > &B) const
Type * bitmap
points toward the bitmap
void sub(const vpImage< Type > &B, vpImage< Type > &C) const
bool operator!=(const vpImage< Type > &I) const