use correct graphics format

This commit is contained in:
rsc 2005-01-30 16:28:21 +00:00
parent efe1241109
commit 9fe5a62166

View file

@ -67,7 +67,7 @@ zread(void *va, void *buf, int n)
int nrow = z->nrow; int nrow = z->nrow;
int ncol = z->ncol; int ncol = z->ncol;
uchar *b = buf, *e = b+n, *img; uchar *b = buf, *e = b+n, *img;
int i, pixels; // number of pixels in row that can be sent now int pixels; // number of pixels in row that can be sent now
while(b+3 <= e){ // loop over image rows while(b+3 <= e){ // loop over image rows
if(z->row >= nrow) if(z->row >= nrow)
@ -79,14 +79,8 @@ zread(void *va, void *buf, int n)
pixels = ncol - z->col; pixels = ncol - z->col;
img = z->data + z->width * z->row + 3 * z->col; img = z->data + z->width * z->row + 3 * z->col;
// Plan 9 image format is BGR?!!! memmove(b, img, 3*pixels);
// memmove(b, img, 3*pixels); b += 3*pixels;
// b += 3*pixels;
for(i=0; i<pixels; i++, img += 3){
*b++ = img[2];
*b++ = img[1];
*b++ = img[0];
}
z->col += pixels; z->col += pixels;
if(z->col >= ncol){ if(z->col >= ncol){
@ -129,10 +123,13 @@ memRGB(Memimage *i)
{ {
Memimage *ni; Memimage *ni;
if(i->chan == RGB24) /*
* BGR24 because we want R,G,B in big-endian order. Sigh.
*/
if(i->chan == BGR24)
return i; return i;
ni = allocmemimage(i->r, RGB24); ni = allocmemimage(i->r, BGR24);
if(ni == nil) if(ni == nil)
return ni; return ni;
memimagedraw(ni, ni->r, i, i->r.min, nil, i->r.min, S); memimagedraw(ni, ni->r, i, i->r.min, nil, i->r.min, S);