libtiff alpha problems

libtiff alpha problems

Post by Peter Melchar » Thu, 22 Apr 1999 04:00:00



this may be the wrong group, but it's urgent, and maybe someone got
experience with libtiff...

I'm using libtiff v3.4 on win32 and I've got the following
problem:

When I'm reading an image with
    ret=TIFFReadRGBAImage(tiffile, width, height, buffer, 0);
the RGB-values are read correctly, but the alpha-components
are
copletely ignored....

When I'm using
    TIFFRGBAImageBegin(&img, tifimage, 0, emsg),
img.alpha==0, while img.bitsperpixel==8 and
img.samplesperpixel==4. So
there is actually a 4th component per pixel, but it's not
recognized as
alpha.

Which function-calls do I have to use to get the correct
alpha-values ?

Thanks in advance.

Peter

 
 
 

1. Problems with libtiff and resolutions

Hi,

    I'm trying to use libtiff on a Macintosh to generate tiff files with
a specified resolution.  The tiff file is build OK, but no matter what I
do the resolution always resets to 0.  This leaves my TIFF to be
interpreted as 25dpi.
    Any help on what I'm doing wrong would be greatly appreciated.

Here's my code:

------------------------------------------------------------------------

  TIFF * tif = TIFFOpen("test.tif", "w");
  if (tif)
  {
   unsigned long width = gPortRect.right - gPortRect.left;
   unsigned long height = gPortRect.bottom - gPortRect.top;
   Boolean bDebug = false;

  bDebug = TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
   TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
   TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
  TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3);
   TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
   TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
   TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
  TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);

   TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP,
1);//TIFFDefaultStripSize(tif, (unsigned long)-1));
     bDebug = TIFFSetField(tif, TIFFTAG_XRESOLUTION, resolution);
   bDebug = TIFFSetField(tif, TIFFTAG_YRESOLUTION, resolution);
    bDebug = TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);
    unsigned int linebytes = 3 * width;

  unsigned char * buf = NULL;

  if (TIFFScanlineSize(tif) > linebytes)
   buf = (unsigned char *) _TIFFmalloc(linebytes);
  else
   buf = (unsigned char *) _TIFFmalloc(TIFFScanlineSize(tif));

  for (int y = 0; y < height; y++)
   {
    for (int x = 0; x < width; x++)
    {
     RGBColor color;
     GetCPixel(x, y, &color);

     buf[(x * 3)] = (unsigned char) (color.red >> 8);
     buf[(x * 3) + 1] = (unsigned char) (color.green >> 8);
     buf[(x * 3) + 2] = (unsigned char) (color.blue >> 8);
    }
    TIFFWriteScanline(tif, buf, y, 0);
   }

   _TIFFfree(buf);

   TIFFClose(tif);
 }

2. Grain removal

3. libtiff problem with TIFFReadRGBAImage

4. FS EKTRON CCD Camera Model 1412 4k X $k

5. Problems with libtiff and resolution

6. Hollywood Hits, Virtual Reality

7. Do you know ImageMagick?

8. Problem with Leffler's libtiff: TIFFDefaultDirectory

9. libtiff library problems

10. libtiff for win95/NT ???

11. Help! compiling LIBTIFF under Sun acc