26 unsigned long int size;
30 if (ptr_ifd==NULL)
return NULL;
34 if (size<=0 ||
buf==NULL) {
43 if (ptr_ifd[num]==NULL)
break;
51 for (i=0; i<num; i++) {
80 if (
buf[0]==
'I' &&
buf[1]==
'I') {
83 else if (
buf[0]==
'M' &&
buf[1]==
'M') {
90 unsigned char* ptr =
buf + 2;
91 short version = *((
short*)ptr);
98 unsigned int offset = *((
unsigned int*)ptr);
103 while (k!=num && offset!=0) {
106 short nn = *((
short*)ptr);
115 memset(ifd, 0,
sizeof(
TIFF_ifd)*(nn+1));
117 memset(&ifd[0], 0, 12);
121 for (i=1; i<=nn; i++) {
123 memcpy(&ifd[i], ptr, 12);
136 for (i=0; i<nn; i++) ptr += 12;
139 offset = *((
unsigned int*)ptr);
143 if (ifd!=NULL) ifd[0].
value = offset;
151 int cnt = ptr->
count;
152 int width=0, height=0, depth=1, bdepth=1, comp=1, color=0;
153 int tilew=0, tileh=0;
159 memset(&vp, 0,
sizeof(
MSGraph));
161 for (i=1; i<=cnt; i++) {
166 ifd->
ex_value = (
void*)malloc(offsize);
183 else if (ifd->
count>=2) {
184 for (j=0, depth=0; j<(int)ifd->
count; j++) {
188 bdepth = (depth+7)/8;
212 memcpy(vp.
gp,
buf+ifd->
value, width*height*bdepth);
225 unsigned char* img = (
unsigned char*)vp.
gp;
226 for (j=0; j<(int)ifd->
count; j++) {
229 memcpy(img,
buf+img_ptr, size);
245 if (tilew>0 && tileh>0) {
246 int xnum = (width +tilew-1)/tilew;
247 int ynum = (height+tileh-1)/tileh;
253 int size = tilew*tileh*bdepth;
255 for (j=0; j<(int)ifd->
count; j++) {
257 memcpy(mp.
gp,
buf+img_ptr, size);
262 for (k=0; k<tileh; k++) {
264 int yy = (jj*tileh + k)*vp.
xs;
265 for (l=0; l<tilew; l++) {
266 int ll = (kk + l)*bdepth;
267 int xx = (yy + ii*tilew + l)*bdepth;
268 for (m=0; m<bdepth; m++) {
269 vp.
gp[xx+m] = mp.
gp[ll+m];
284 int block = tilew*tileh*bdepth;
285 for (j=0; j<(int)ifd->
count; j++) {
288 PRINT_MESG(
"PROC_TIFF_IFD: Not match Tile Size %d != %d\n", block, size);
314 if (max_values<0) max_values = 0;
317 int num = ifd->
count;
319 for (i=1; i<=num; i++) {
334 if (max_values<0) max_values = 0;
336 fprintf(fp,
"%5d %2d %d -> ", ifd->
tag, ifd->
type, ifd->
count);
339 int count =
Min((
int)ifd->
count, max_values);
356 else if (count>0) fprintf(fp,
" PRINT_TIFF_IFD_INDIV: not supported IFD type => %d", ifd->
type);
360 else fprintf(fp,
" %d", ifd->
value);
369 if (ifd==NULL)
return;
377 if (ptr_ifd==NULL)
return;
380 while ((*ptr)!=NULL) {
381 if ((*ptr)->tag==0) {
382 if ((*ptr)->ex_value!=NULL) {
397 if (ifd==NULL)
return NULL;
399 if (offset<0) offset = 0;
402 unsigned char* ptr = NULL;
405 else ptr = (
unsigned char*)&(ifd->
value);
407 return (
char*)(ptr + offset);
413 if (ifd==NULL)
return 0;
417 if (offset<0) offset = 0;
419 unsigned int ret = 0;
421 unsigned char* ptr = NULL;
424 else ptr = (
unsigned char*)&(ifd->
value);
430 else ret = *(
unsigned short*)(ptr + offset*2);
434 else ret = *(
unsigned int*)(ptr + offset*4);
443 if (ifd==NULL)
return 0.0;
445 if (offset<0) offset = 0;
449 unsigned char* ptr = NULL;
452 else ptr = (
unsigned char*)&(ifd->
value);
455 ret = *(
float*)(ptr + offset*4);
458 ret = *(
double*)(ptr + offset*8);
467 int byte_num[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
469 if (type>0 && type<13)
return byte_num[type];
476 if (ifd==NULL && tag<=0)
return NULL;
479 int count = ifd->
count;
482 if (ifd->
tag==tag)
return ifd;
487 for (i=0; i<count; i++) {
488 if (ifd->
tag==tag)
return ifd;
MSGraph make_MSGraph(int xs, int ys, int zs, int depth)
unsigned char * gp
グラフィックデータへのポインタ. xs*ys*zs*depth.