2002.10.01 04:36 "Re: Seek help", by Peter Montgomery
An unsigned char will allows the values from 0 to 255. The array size can be as big as you want, just declare it or malloc it with enough memory. The statement "unsigned char buffer" will give allow up to a 10 X 10 (or 2 X 50, etc) image with values from 0 to 255. You say that "t only can be used to save single character". Is the compiler giving you an error message? If so, then what is the exact error message and what is the exact line of code that it is complaining about. Arrays in C are very closely tied to pointers, and if you're not too familiar with C, it's easy to get the code wrong.
Cc: "Zhongfu Zhou" <firstname.lastname@example.org>; "TIFF Mailing
Sent: Monday, September 30, 2002 11:23 AM
Subject: Re: Seek help
Thank you very much for your direction. I urgly need to generate some images from data produced in my simulating programme by Fortran. I have
spent two days and tried many methods to deal with it, but it still
doesn't work. I am really not familar with both C and tifflib.
Actually I want to set the levels of gray up to 256, i.e. the data marix maybe like, not only 0 and 1:
1, 120, 126...
30, 45, 0...
and the size maybe till 1000*1000.
I tried to define "unsigned char buffer", but it only can be used to save single character.
In message <3D989131.email@example.com> firstname.lastname@example.org writes:
> Zhongfu Zhou wrote:
> > uint32 lSize;
> > int buffer;
> > TIFFSetField(image,TIFFTAG_BITSPERSAMPLE, 8);
> > TIFFWriteEncodedStrip(image,0,buffer,100);
> Your fundamental mistake is using a 32 bit integer buffer 'buffer', when
> actually writing an 8bit per sample image. Try declaring buffer as
> "unsigned char buffer" instead. I haven't tried your code so there
> may be other problems as well.
> > Frank Warmerdam, email@example.com