aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/jpg
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-01-30 16:28:21 +0000
committerrsc <devnull@localhost>2005-01-30 16:28:21 +0000
commit9fe5a6216669a8f32c9bb6375b396db88961f7d8 (patch)
treed7a2cbb5abd65ea545c16d0f141651616a5ced3c /src/cmd/jpg
parentefe12411090ddcb45f524d6b0624ec4493d65175 (diff)
downloadplan9port-9fe5a6216669a8f32c9bb6375b396db88961f7d8.tar.gz
plan9port-9fe5a6216669a8f32c9bb6375b396db88961f7d8.tar.bz2
plan9port-9fe5a6216669a8f32c9bb6375b396db88961f7d8.zip
use correct graphics format
Diffstat (limited to 'src/cmd/jpg')
-rw-r--r--src/cmd/jpg/writepng.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/cmd/jpg/writepng.c b/src/cmd/jpg/writepng.c
index 44bfe10c..fb6026d0 100644
--- a/src/cmd/jpg/writepng.c
+++ b/src/cmd/jpg/writepng.c
@@ -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)
@@ -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){
@@ -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);