tuse correct graphics format - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 9fe5a6216669a8f32c9bb6375b396db88961f7d8
 (DIR) parent efe12411090ddcb45f524d6b0624ec4493d65175
 (HTM) Author: rsc <devnull@localhost>
       Date:   Sun, 30 Jan 2005 16:28:21 +0000
       
       use correct graphics format
       
       Diffstat:
         M src/cmd/jpg/writepng.c              |      19 ++++++++-----------
       
       1 file changed, 8 insertions(+), 11 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/jpg/writepng.c b/src/cmd/jpg/writepng.c
       t@@ -67,7 +67,7 @@ zread(void *va, void *buf, int n)
                int nrow = z->nrow;
                int ncol = z->ncol;
                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
                        if(z->row >= nrow)
       t@@ -79,14 +79,8 @@ zread(void *va, void *buf, int n)
                                pixels = ncol - z->col;
                        img = z->data + z->width * z->row + 3 * z->col;
        
       -                // Plan 9 image format is BGR?!!!
       -                // memmove(b, img, 3*pixels);
       -                // b += 3*pixels;
       -                for(i=0; i<pixels; i++, img += 3){
       -                        *b++ = img[2];
       -                        *b++ = img[1];
       -                        *b++ = img[0];
       -                }
       +                memmove(b, img, 3*pixels);
       +                b += 3*pixels;
        
                        z->col += pixels;
                        if(z->col >= ncol){
       t@@ -129,10 +123,13 @@ memRGB(Memimage *i)
        {
                Memimage *ni;
        
       -        if(i->chan == RGB24)
       +        /*
       +         * BGR24 because we want R,G,B in big-endian order.  Sigh.
       +         */
       +        if(i->chan == BGR24)
                        return i;
        
       -        ni = allocmemimage(i->r, RGB24);
       +        ni = allocmemimage(i->r, BGR24);
                if(ni == nil)
                        return ni;
                memimagedraw(ni, ni->r, i, i->r.min, nil, i->r.min, S);