ref: 0b4b45f393d13203752160695b3326d769cbead3
dir: /test/t.c/
#include <u.h>
#include <libc.h>
#include <ctype.h>
#include "../icc.h"
void
readattrs(char *s, u64int attr)
{
s += sprint(s, "%s ", attr&IDTransparent ? "transparent" : "reflective");
s += sprint(s, "%s ", attr&IDMatte ? "matte" : "glossy");
s += sprint(s, "%s ", attr&IDNegative ? "negative" : "positive");
s += sprint(s, "%s", attr&IDMono ? "mono" : "color");
}
void
asascii(char *out, u32int data)
{
char a, b, c, d;
a = (data>>24)&0xff;
b = (data>>16)&0xff;
c = (data>>8 )&0xff;
d = (data>>0 )&0xff;
if (!(isalnum(a) || isalnum(b) || isalnum(c) || isalnum(d))) {
out[0] = 0;
return;
}
out[0] = a;
out[1] = b;
out[2] = c;
out[3] = d;
out[4] = 0;
}
void
main(void)
{
char buf[512];
double dx, dy, dz;
ICCprofile *prof;
ICCdate d;
int fd;
int n;
fd = open("sRGB_v4_ICC_preference.icc", OREAD);
prof = iccload(fd);
close(fd);
fprint(2, "size: %d\n", prof->size);
fprint(2, "cmm: %d\n", prof->cmm);
fprint(2, "vers: %d.%d.%d\n", prof->vmajor, prof->vminor, prof->vbugfix);
fprint(2, "class: %s\n", iccgetclass(prof));
fprint(2, "data: %s\n", iccgetdataspace(prof));
fprint(2, "pcs: %s\n", iccgetpcs(prof));
d = prof->creationdate;
fprint(2, "cdate: %4d.%02d.%02d %02d:%02d:%02d\n", d.year, d.month, d.day, d.hours, d.minutes, d.seconds);
fprint(2, "plat: %s\n", prof->platform);
fprint(2, "dmanu: %d\n", prof->devmanufacturer);
fprint(2, "dmodel: %d\n", prof->devmodel);
readattrs(buf, prof->devattrs);
fprint(2, "dattrs: %s\n", buf);
fprint(2, "intent: %d\n", prof->rendintent);
dx = s15f16tod(prof->illuminant.x);
dy = s15f16tod(prof->illuminant.y);
dz = s15f16tod(prof->illuminant.z);
fprint(2, "illum: %f %f %f\n", dx, dy, dz);
fprint(2, "creatr: %d\n", prof->creator);
n = enc64(buf, sizeof buf, prof->id, sizeof prof->id);
fprint(2, "id: %*s\n", n, buf);
fprint(2, "ntags: %d\n", prof->ntags);
for (n = 0; n < prof->ntags; n++) {
fprint(2, " tag: %d\n", n);
asascii(buf, prof->tags[n].signature);
fprint(2, " signature: %x (%4s)\n", prof->tags[n].signature, *buf ? buf : "");
fprint(2, " offset: %d\n", prof->tags[n].offset);
fprint(2, " size: %d\n", prof->tags[n].size);
}
exits(nil);
}