AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
January 2010

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2010.01.08 23:53 "me again...", by Kavallieratou Ergina
2010.01.09 01:14 "Re: me again...", by Bob Friesenhahn
2010.01.11 09:47 "Re: me again...", by Gerben Vos

2010.01.08 23:53 "me again...", by Kavallieratou Ergina

Brad, first of all I would like to thank you for your answer. But I still
have problems.

imagen is a black and white image that I have loaded from a bmp file. It is
imagen->height=3290
imagen->width = 2552
imagen->bits_per_pixel=8;
the imagen->data includes only 0s (background) and 1s (foreground)

I wish to save it as a tiff image. Your remark sounds logical and I did it,
however now it stops running when y=2 in

if (TIFFWriteScanline(out,bits, y, 0)==-1) cout<<"Complete or error";

I am not sure if in either of
TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 1);
TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 1);

the 1 should be 8. I tried all of them but the program always stops at the
same point.
any more suggestions ? Please help!

I attach the code here.
thank you again

struct gen
{
unsigned char ** data;
unsigned short int width;
unsigned short int height;
unsigned short int bits_per_pixel;
};

struct gen imagen;

TIFF *out= TIFFOpen("ar.tif", "w");

TIFFSetField (out, TIFFTAG_IMAGEWIDTH, imagen->width);
TIFFSetField(out, TIFFTAG_IMAGELENGTH, imagen->height);
TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 1);
TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 1);
TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
BYTE *bits;
for (int y = 0; y < imagen->height; y++)
{
bits= imagen->data[y*imagen->width];
if (TIFFWriteScanline(out,bits, y, 0)==-1) cout<<"Complete or error";
}