MCPcopy Create free account
hub / github.com/LibRaw/LibRaw / tiff_head

Method tiff_head

src/write/file_write.cpp:58–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56#define TOFF(ptr) int((char *)(&(ptr)) - (char *)th)
57
58void LibRaw::tiff_head(struct tiff_hdr *th, int full)
59{
60 int c, psize = 0;
61 struct tm *t;
62
63 memset(th, 0, sizeof *th);
64 th->t_order = htonl(0x4d4d4949) >> 16;
65 th->magic = 42;
66 th->ifd = 10;
67 th->rat[0] = th->rat[2] = 300;
68 th->rat[1] = th->rat[3] = 1;
69 FORC(6) th->rat[4 + c] = 1000000;
70 th->rat[4] = int(shutter * 1000000.f);
71 th->rat[6] = int(aperture * 1000000.f);
72 th->rat[8] = int(focal_len * 1000000.f);
73 strncpy(th->t_desc, desc, 512);
74 strncpy(th->t_make, make, 64);
75 strncpy(th->t_model, model, 64);
76 strcpy(th->soft, "dcraw v" DCRAW_VERSION);
77 t = localtime(&timestamp);
78 sprintf(th->date, "%04d:%02d:%02d %02d:%02d:%02d", t->tm_year + 1900,
79 t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
80 strncpy(th->t_artist, artist, 64);
81 if (full)
82 {
83 tiff_set(th, &th->ntag, 254, 4, 1, 0);
84 tiff_set(th, &th->ntag, 256, 4, 1, width);
85 tiff_set(th, &th->ntag, 257, 4, 1, height);
86 tiff_set(th, &th->ntag, 258, 3, colors, output_bps);
87 if (colors > 2)
88 th->tag[th->ntag - 1].val.i = TOFF(th->bps);
89 FORC4 th->bps[c] = output_bps;
90 tiff_set(th, &th->ntag, 259, 3, 1, 1);
91 tiff_set(th, &th->ntag, 262, 3, 1, 1 + (colors > 1));
92 }
93 tiff_set(th, &th->ntag, 270, 2, 512, TOFF(th->t_desc));
94 tiff_set(th, &th->ntag, 271, 2, 64, TOFF(th->t_make));
95 tiff_set(th, &th->ntag, 272, 2, 64, TOFF(th->t_model));
96 if (full)
97 {
98 if (oprof)
99 psize = ntohl(oprof[0]);
100 tiff_set(th, &th->ntag, 273, 4, 1, sizeof *th + psize);
101 tiff_set(th, &th->ntag, 277, 3, 1, colors);
102 tiff_set(th, &th->ntag, 278, 4, 1, height);
103 tiff_set(th, &th->ntag, 279, 4, 1,
104 height * width * colors * output_bps / 8);
105 }
106 else
107 tiff_set(th, &th->ntag, 274, 3, 1, "12435867"[flip] - '0');
108 tiff_set(th, &th->ntag, 282, 5, 1, TOFF(th->rat[0]));
109 tiff_set(th, &th->ntag, 283, 5, 1, TOFF(th->rat[2]));
110 tiff_set(th, &th->ntag, 284, 3, 1, 1);
111 tiff_set(th, &th->ntag, 296, 3, 1, 2);
112 tiff_set(th, &th->ntag, 305, 2, 32, TOFF(th->soft));
113 tiff_set(th, &th->ntag, 306, 2, 20, TOFF(th->date));
114 tiff_set(th, &th->ntag, 315, 2, 64, TOFF(th->t_artist));
115 tiff_set(th, &th->ntag, 34665, 4, 1, TOFF(th->nexif));

Callers

nothing calls this directly

Calls 2

tiff_setFunction · 0.85
FORCFunction · 0.50

Tested by

no test coverage detected