59 IplImage *pIplImage = cvLoadImage(pFilePath);
63 if (pIplImage->nChannels != 3 && pIplImage->nChannels != 1)
65 cvReleaseImage(&pIplImage);
73 pImage->
width = pIplImage->width;
74 pImage->
height = pIplImage->height;
79 const int nPaddingBytes = pIplImage->widthStep - pImage->
bytesPerPixel * pIplImage->width;
80 const unsigned char *input = (
unsigned char *) pIplImage->imageData;
81 unsigned char *output = pImage->
pixels;
82 const int width = pImage->
width;
83 const int height = pImage->
height;
87 for (
int y = 0, i_input = 0, i_output = 0; y < height; y++, i_input += nPaddingBytes)
89 for (
int x = 0; x < width; x++, i_input++, i_output++)
90 output[i_output] = input[i_input];
95 for (
int y = 0, i_input = 0, i_output = 0; y < height; y++, i_input += nPaddingBytes)
97 for (
int x = 0; x < width; x++, i_input += 3, i_output += 3)
99 output[i_output] = input[i_input + 2];
100 output[i_output + 1] = input[i_input + 1];
101 output[i_output + 2] = input[i_input];
107 printf(
"error: CByteImage::eRGB24Split not supported by ImageAccessCV::LoadFromFile\n");
110 cvReleaseImage(&pIplImage);
123 nRet = cvSaveImage(pFilePath, pIplImage);
124 cvReleaseImageHeader(&pIplImage);
128 const int width = pImage->
width;
129 const int height = pImage->
height;
130 const int nBytes = width * height * 3;
134 const unsigned char *input = pImage->
pixels;
135 unsigned char *output = tempImage.
pixels;
137 for (
int i = 0; i < nBytes; i += 3)
139 output[i] = input[i + 2];
140 output[i + 1] = input[i + 1];
141 output[i + 2] = input[i];
145 nRet = cvSaveImage(pFilePath, pIplImage);
146 cvReleaseImageHeader(&pIplImage);
150 printf(
"error: CByteImage::eRGB24Split not supported by ImageAccessCV::SaveToFile\n");
bool m_bOwnMemory
Flag signaling if memory is to be freed or not.
bool LoadFromFile(CByteImage *pImage, const char *pFilePath)
Loads an image from a file.
IplImage * Adapt(const CByteImage *pImage, bool bAllocateMemory=false)
Converts a CByteImage to an IplImage.
ImageType type
The type of the image.
int width
The width of the image in pixels.
int height
The height of the image in pixels.
bool SaveToFile(const CByteImage *pImage, const char *pFilePath)
Saves an image to a file.
unsigned char * pixels
The pointer to the the pixels.
Data structure for the representation of 8-bit grayscale images and 24-bit RGB (or HSV) color images ...
int bytesPerPixel
The number of bytes used for encoding one pixel.