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
This commit is contained in:
parent
f104cc9d79
commit
243cb68011
7 changed files with 20 additions and 26 deletions
|
@ -4,7 +4,7 @@ jpg, gif, png, tif, ppm, bmp, v210, yuv, ico, tga, tojpg, togeordi, togif, toppm
|
|||
.SH SYNOPSIS
|
||||
.B jpg
|
||||
[
|
||||
.B -39cdefFkJrtv
|
||||
.B -39cdefFkJrtvy
|
||||
] [
|
||||
.I file ...
|
||||
]
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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/
|
||||
|
|
Loading…
Reference in a new issue