ref: 243cb68011ac5335bb2f9fc146d0f6be2d283fa9
parent: f104cc9d79940e4f2c15ceaafa765a3cc94c817f
author: ppatience0 <ppatience0@gmail.com>
date: Sat Aug 31 09:39:51 EDT 2013
jpg(1), jpg: add -y flag to usage png: colorspace will never be CYCbCr (this is no doubt from copy-pasting from jpg) tif: everyone else uses colorspace as a function argument, so we will too readtif, writetif: credit paul bourke
--- a/sys/man/1/jpg
+++ b/sys/man/1/jpg
@@ -4,7 +4,7 @@
.SH SYNOPSIS
.B jpg
[
-.B -39cdefFkJrtv
+.B -39cdefFkJrtvy
] [
.I file ...
]
--- a/sys/src/cmd/jpg/imagefile.h
+++ b/sys/src/cmd/jpg/imagefile.h
@@ -53,8 +53,8 @@
Rawimage** Breadjpg(Biobuf*, int);
Rawimage** readpng(int, int);
Rawimage** Breadpng(Biobuf*, int);
-Rawimage** readtif(int);
-Rawimage** Breadtif(Biobuf*);
+Rawimage** readtif(int, int);
+Rawimage** Breadtif(Biobuf*, int);
Rawimage** readgif(int, int);
Rawimage** readpixmap(int, int);
Rawimage* torgbv(Rawimage*, int);
--- a/sys/src/cmd/jpg/jpg.c
+++ b/sys/src/cmd/jpg/jpg.c
@@ -110,7 +110,7 @@
outchan = CMAP8;
break;
default:
- fprint(2, "usage: jpg -39cdefFkJrtv [file.jpg ...]\n");
+ fprint(2, "usage: jpg -39cdefFkJrtvy [file.jpg ...]\n");
exits("usage");}ARGEND;
--- a/sys/src/cmd/jpg/png.c
+++ b/sys/src/cmd/jpg/png.c
@@ -11,7 +11,6 @@
int eflag = 0;
int nineflag = 0;
int threeflag = 0;
-int colorspace = CRGB;
int output = 0;
ulong outchan = CMAP8;
Image *image;
@@ -48,7 +47,6 @@
{int fd, i;
char *err;
- char buf[12+1];
ARGBEGIN{case 'c': /* produce encoded, compressed, bitmap file; no display by default */
@@ -71,9 +69,6 @@
defaultcolor = 0;
outchan = GREY8;
break;
- case 'r':
- colorspace = CRGB;
- break;
case '3': /* produce encoded, compressed, three-color bitmap file; no display by default */
threeflag++;
/* fall through */
@@ -100,16 +95,6 @@
exits("usage");}ARGEND;
- if(dflag==0 && colorspace==CYCbCr){ /* see if we should convert right to RGB */- fd = open("/dev/screen", OREAD);- if(fd > 0){- buf[12] = '\0';
- if(read(fd, buf, 12)==12 && chantodepth(strtochan(buf))>8)
- colorspace = CRGB;
- close(fd);
- }
- }
-
err = nil;
if(argc == 0)
err = show(0, "<stdin>", outchan);
@@ -146,7 +131,7 @@
if(Binit(&b, fd, OREAD) < 0)
return nil;
outchan = outc;
- array = Breadpng(&b, colorspace);
+ array = Breadpng(&b, CRGB);
if(array == nil || array[0]==nil){fprint(2, "png: decode %s failed: %r\n", name);
return "decode";
--- a/sys/src/cmd/jpg/readtif.c
+++ b/sys/src/cmd/jpg/readtif.c
@@ -1,12 +1,14 @@
/*
* code/documentation:
* http://partners.adobe.com/public/developer/en/tiff/TIFF6.pdf
-* http://paulbourke.net/dataformats/tiff/
* http://www.fileformat.info/format/tiff/egff.htm
* http://www.fileformat.info/mirror/egff/ch09_05.htm
* http://www.itu.int/rec/T-REC-T.4-199904-S/en
* http://www.itu.int/rec/T-REC-T.6-198811-I/en
*
+* many thanks to paul bourke for a simple description of tiff:
+* http://paulbourke.net/dataformats/tiff/
+*
* copy-pasted fax codes and lzw help:
* http://www.remotesensing.org/libtiff/
*/
@@ -1797,11 +1799,16 @@
}
Rawimage **
-Breadtif(Biobuf *b)
+Breadtif(Biobuf *b, int colorspace)
{Rawimage **array, *r;
Tif *t;
+ if(colorspace != CRGB24) {+ werrstr("unknown color space: %d",+ colorspace);
+ return nil;
+ }
if((t = malloc(sizeof *t)) == nil)
return nil;
if((array = malloc(2*sizeof *array)) == nil)
@@ -1842,7 +1849,7 @@
}
Rawimage **
-readtif(int fd)
+readtif(int fd, int colorspace)
{Rawimage **a;
Biobuf b;
@@ -1849,7 +1856,7 @@
if(Binit(&b, fd, OREAD) < 0)
return nil;
- a = Breadtif(&b);
+ a = Breadtif(&b, colorspace);
Bterm(&b);
return a;
}
--- a/sys/src/cmd/jpg/tif.c
+++ b/sys/src/cmd/jpg/tif.c
@@ -165,7 +165,7 @@
if(Binit(&b, fd, OREAD) < 0)
return nil;
- array = Breadtif(&b);
+ array = Breadtif(&b, CRGB24);
if(array == nil || array[0] == nil) {if(array != nil)
free(array);
--- a/sys/src/cmd/jpg/writetif.c
+++ b/sys/src/cmd/jpg/writetif.c
@@ -1,11 +1,13 @@
/*
* code/documentation:
* http://partners.adobe.com/public/developer/en/tiff/TIFF6.pdf
-* http://paulbourke.net/dataformats/tiff/
* http://www.fileformat.info/format/tiff/egff.htm
* http://www.fileformat.info/mirror/egff/ch09_05.htm
* http://www.itu.int/rec/T-REC-T.4-199904-S/en
* http://www.itu.int/rec/T-REC-T.6-198811-I/en
+*
+* many thanks to paul bourke for a simple description of tiff:
+* http://paulbourke.net/dataformats/tiff/
*
* copy-pasted fax codes and copy-pasted lzw encoding
* hash table implementation:
--
⑨