2013-07-12 4 views
0

그래서이 프로그램은 아직 완성되지 않았습니다. 내 이미지는 8 비트 또는 16 비트입니다. buf에서 나오는 값을 버퍼 배열에 어떻게 할당합니까? 바로 지금, printf는 buf가 void 타입이라고 말했기 때문에 buf가 작동하지 않는다. ... 나는 어떻게 처리해야할지 모른다.libtiff를 사용하여 TIFF 그레이 스케일 읽기

void read_tiff(image_file_name,buffer) 
     char image_file_name[]; 
     short **buffer; 
{ 
    int i,j; 
    tsize_t scanline; 
    tdata_t buf; 
uint32 width; 
uint32 height; 
TIFF *tif = TIFFOpen(image_file_name,"r"); 

if(tif){ 
TIFFGetField(tif,TIFFTAG_IMAGEWIDTH, &width); 
TIFFGetField(tif,TIFFTAG_IMAGELENGTH, &height); 

buf = _TIFFmalloc(TIFFScanlineSize(tif)); 


printf("width height %d %d\n",width,height); 
for(i=0;i<height;i++){ 
    TIFFReadScanline(tif,buf,i); 
    printf("%d ",buf[j]); 
} 

_TIFFfree(buf); 
TIFFClose(tif); 
} 
else{ 
    printf("ERROR- cannot open image %s\n",image_file_name); 
} 
} 

답변

1

void *을 역 참조 할 수 없으므로 이전에 캐스팅해야합니다. 예를 들어

, 당신은 바이트에 캐스팅 경우 :

printf("%d ", ((unsigned char *) buf)[j]); 
관련 문제