34 #ifndef VP_IMAGE_OPERATOR_H
35 #define VP_IMAGE_OPERATOR_H
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)) {
70 std::ios_base::fmtflags original_flags = s.flags();
71 const unsigned int magic_3 = 3;
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);
99 std::ios_base::fmtflags original_flags = s.flags();
100 const unsigned int magic_4 = 4;
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);
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);
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);
192 if (display !=
nullptr) {
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)))
214 template <class Type> vpImage<Type> &vpImage<Type>::operator=(vpImage<Type> &&other)
216 if (row !=
nullptr) {
220 if (bitmap !=
nullptr && hasOwnership) {
223 bitmap = other.bitmap;
225 if (display !=
nullptr) {
226 if ((height != other.height) || (width != other.width)) {
228 "Error in vpImage::operator=(&) where the display is initialised but the image size is different"));
231 if (other.display !=
nullptr) {
233 "Error in vpImage::operator=(&&) where the display of the image to move is initialised"));
235 height = other.height;
237 npixels = other.npixels;
238 hasOwnership = other.hasOwnership;
240 other.bitmap =
nullptr;
241 other.display =
nullptr;
246 other.hasOwnership =
false;
260 for (
unsigned int i = 0; i < npixels; ++i) {
285 for (
unsigned int i = 0; i < npixels; ++i) {
286 if (bitmap[i] != I.
bitmap[i]) {
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
error that can be emitted by ViSP classes.
@ dimensionError
Bad dimension.
Definition of the vpImage class member functions.
vpImage< Type > & operator=(const vpImage< Type > &other)
Copy operator.
unsigned int getWidth() const
bool operator==(const vpImage< Type > &I) const
vpImage< Type > operator-(const vpImage< Type > &B) const
Type * bitmap
points toward the bitmap
unsigned int getHeight() const
bool operator!=(const vpImage< Type > &I) const