53 IplImage *pIplImage = cvLoadImage(pFilePath);
57 if (pIplImage->nChannels != 3 && pIplImage->nChannels != 1)
59 cvReleaseImage(&pIplImage);
67 pImage->
width = pIplImage->width;
68 pImage->
height = pIplImage->height;
73 const int nPaddingBytes = pIplImage->widthStep - pImage->
bytesPerPixel * pIplImage->width;
74 const unsigned char *
input = (
unsigned char *) pIplImage->imageData;
75 unsigned char *output = pImage->
pixels;
81 for (
int y = 0, i_input = 0, i_output = 0;
y <
height;
y++, i_input += nPaddingBytes)
83 for (
int x = 0;
x <
width;
x++, i_input++, i_output++)
84 output[i_output] = input[i_input];
89 for (
int y = 0, i_input = 0, i_output = 0;
y <
height;
y++, i_input += nPaddingBytes)
91 for (
int x = 0;
x <
width;
x++, i_input += 3, i_output += 3)
93 output[i_output] = input[i_input + 2];
94 output[i_output + 1] = input[i_input + 1];
95 output[i_output + 2] = input[i_input];
101 printf(
"error: CByteImage::eRGB24Split not supported by ImageAccessCV::LoadFromFile\n");
104 cvReleaseImage(&pIplImage);
117 nRet = cvSaveImage(pFilePath, pIplImage);
118 cvReleaseImageHeader(&pIplImage);
124 const int nBytes = width * height * 3;
129 unsigned char *output = tempImage.
pixels;
131 for (
int i = 0; i < nBytes; i += 3)
133 output[i] = input[i + 2];
134 output[i + 1] = input[i + 1];
135 output[i + 2] = input[i];
139 nRet = cvSaveImage(pFilePath, pIplImage);
140 cvReleaseImageHeader(&pIplImage);
144 printf(
"error: CByteImage::eRGB24Split not supported by ImageAccessCV::SaveToFile\n");
int width
The width of the image in pixels.
bool SaveToFile(const CByteImage *pImage, const char *pFilePath)
Saves an image to a file.
Data structure for the representation of 8-bit grayscale images and 24-bit RGB (or HSV) color images ...
bool m_bOwnMemory
Flag signaling if memory is to be freed or not.
unsigned char * pixels
The pointer to the the pixels.
bool LoadFromFile(CByteImage *pImage, const char *pFilePath)
Loads an image from a file.
int height
The height of the image in pixels.
int bytesPerPixel
The number of bytes used for encoding one pixel.
GLenum GLsizei GLsizei height
GLenum GLenum GLenum input
ImageType type
The type of the image.
IplImage * Adapt(const CByteImage *pImage, bool bAllocateMemory=false)
Converts a CByteImage to an IplImage.