Support for BGR image interleaved.
cgringmuth opened this issue · 3 comments
Hi, I have an image buffer with BGR interleaved. It is not clear to me, how to represent this correctly in CImg.
CImg<unsigned char> img = CImg<unsigned char>(buffter,3,W,H).permute_axes("zyxc");
Somewhat does the trick, but the color is still wrong. Can you tell me, what I'm doing wrong?
Best.
I'd say it should be:
CImg<unsigned char> img = CImg<unsigned char>(buffter,3,W,H).permute_axes("yzcx");
Wow... this was fast. Thx
I was wondering something else. Is this code snippet correct?
default : {
cimg_forY(*this,y) {
cimg_forX(*this,x) {
std::fputc((unsigned char)(*(ptr_b++)),nfile);
std::fputc((unsigned char)(*(ptr_g++)),nfile);
std::fputc((unsigned char)(*(ptr_r++)),nfile);
}
cimg::fwrite(align_buf,align,nfile);
ptr_r-=2*_width; ptr_g-=2*_width; ptr_b-=2*_width;
}
In my limited understanding it first save blue, then green and then red. But I though BMP saves RGB instead? You can find this in _save_bmp
.
In my limited understanding if first save blue, then green and then red.
That is what it does indeed. If it's like this in save_bmp
, then it's probably how the data are stored in a .bmp file.