summaryrefslogtreecommitdiff
path: root/sys/src/cmd/jpg
diff options
context:
space:
mode:
authorppatience0 <ppatience0@gmail.com>2013-08-31 13:39:51 -0400
committerppatience0 <ppatience0@gmail.com>2013-08-31 13:39:51 -0400
commit243cb68011ac5335bb2f9fc146d0f6be2d283fa9 (patch)
tree6b6c7af74bb472c8b40ef33032500cfc3ed91ab7 /sys/src/cmd/jpg
parentf104cc9d79940e4f2c15ceaafa765a3cc94c817f (diff)
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
Diffstat (limited to 'sys/src/cmd/jpg')
-rw-r--r--sys/src/cmd/jpg/imagefile.h4
-rw-r--r--sys/src/cmd/jpg/jpg.c2
-rw-r--r--sys/src/cmd/jpg/png.c17
-rw-r--r--sys/src/cmd/jpg/readtif.c15
-rw-r--r--sys/src/cmd/jpg/tif.c2
-rw-r--r--sys/src/cmd/jpg/writetif.c4
6 files changed, 19 insertions, 25 deletions
diff --git a/sys/src/cmd/jpg/imagefile.h b/sys/src/cmd/jpg/imagefile.h
index 0030559a9..13d94a5c3 100644
--- a/sys/src/cmd/jpg/imagefile.h
+++ b/sys/src/cmd/jpg/imagefile.h
@@ -53,8 +53,8 @@ Rawimage** readjpg(int, int);
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);
diff --git a/sys/src/cmd/jpg/jpg.c b/sys/src/cmd/jpg/jpg.c
index 10c768299..307dc347f 100644
--- a/sys/src/cmd/jpg/jpg.c
+++ b/sys/src/cmd/jpg/jpg.c
@@ -110,7 +110,7 @@ main(int argc, char *argv[])
outchan = CMAP8;
break;
default:
- fprint(2, "usage: jpg -39cdefFkJrtv [file.jpg ...]\n");
+ fprint(2, "usage: jpg -39cdefFkJrtvy [file.jpg ...]\n");
exits("usage");
}ARGEND;
diff --git a/sys/src/cmd/jpg/png.c b/sys/src/cmd/jpg/png.c
index d18f55c46..a27461186 100644
--- a/sys/src/cmd/jpg/png.c
+++ b/sys/src/cmd/jpg/png.c
@@ -11,7 +11,6 @@ int dflag = 0;
int eflag = 0;
int nineflag = 0;
int threeflag = 0;
-int colorspace = CRGB;
int output = 0;
ulong outchan = CMAP8;
Image *image;
@@ -48,7 +47,6 @@ main(int argc, char *argv[])
{
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 @@ main(int argc, char *argv[])
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 @@ main(int argc, char *argv[])
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 @@ show(int fd, char *name, int outc)
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";
diff --git a/sys/src/cmd/jpg/readtif.c b/sys/src/cmd/jpg/readtif.c
index ddeecd682..c9a0eec76 100644
--- 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 @@ readslave(Tif *t)
}
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,14 +1849,14 @@ Breadtif(Biobuf *b)
}
Rawimage **
-readtif(int fd)
+readtif(int fd, int colorspace)
{
Rawimage **a;
Biobuf b;
if(Binit(&b, fd, OREAD) < 0)
return nil;
- a = Breadtif(&b);
+ a = Breadtif(&b, colorspace);
Bterm(&b);
return a;
}
diff --git a/sys/src/cmd/jpg/tif.c b/sys/src/cmd/jpg/tif.c
index 91d77abc6..70c4f2282 100644
--- a/sys/src/cmd/jpg/tif.c
+++ b/sys/src/cmd/jpg/tif.c
@@ -165,7 +165,7 @@ show(int fd, char *name, int outchan)
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);
diff --git a/sys/src/cmd/jpg/writetif.c b/sys/src/cmd/jpg/writetif.c
index 02a117694..1606cb229 100644
--- a/sys/src/cmd/jpg/writetif.c
+++ b/sys/src/cmd/jpg/writetif.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 copy-pasted lzw encoding
* hash table implementation:
* http://www.remotesensing.org/libtiff/