AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

1993.08.20 01:22 "help on TIFFReadRGBAImage", by Yip Chi Lap
1993.08.20 09:40 "Re: help on TIFFReadRGBAImage", by Karsten Spang
1993.08.21 01:08 "Re: help on TIFFReadRGBAImage", by Sam Leffler
1993.08.21 02:03 "Re: help on TIFFReadRGBAImage", by Yip Chi Lap
1993.08.22 18:02 "Re: help on TIFFReadRGBAImage", by Sam Leffler
1993.08.22 20:07 "Re: help on TIFFReadRGBAImage", by Sam Leffler
1993.08.23 08:07 "help on TIFFReadRGBAImage", by Oliver Trepte
1993.08.23 04:08 "Re: help on TIFFReadRGBAImage", by Yip Chi Lap
1993.08.23 10:58 "help on TIFFReadRGBAImage", by Oliver Trepte

1993.08.20 01:22 "help on TIFFReadRGBAImage", by Yip Chi Lap

Hello,

I have written a small program to open a TIFF file, read it using TIFFRGBAImage, and then dump the image out byte by byte in hex. I found that the scanline order seems to be reversed.

I scanned archive.May2593-Aug1893 and found only one reference to this function. I use libtiff v3.21 BETA compiled on an multiprocessor sun (`mach`=sparc, `arch`=sun4). The program and the pnm file used to create the tiff file is attached below. Thanks for your help in advance.

Regards,
  Beta.

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

#include <iostream.h> 
#include <stdio.h>
#include <stdlib.h>
#include <tiffio.h>
#include <tiffcomp.h>

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

int main(int argc,char** argv)
{
  TIFF *tif;
  int x,y;
  char st[80];
  unsigned long width, height;
  unsigned long *raster;

  do
  {
    cout<<"Filename: ";
    cin>>st;
  }
  while ((tif=TIFFOpen(st,"r"))==NULL);

  TIFFGetField(tif,TIFFTAG_IMAGEWIDTH,&width); 
  TIFFGetField(tif,TIFFTAG_IMAGELENGTH,&height);
  raster=(unsigned long *)malloc (width*height*sizeof(unsigned long));
  TIFFReadRGBAImage(tif,width,height,raster,0);

  cout<<"contiguous: \n";
  for(y=0;y<height;y++)
  {
    for(x=0;x<width;x++)
      printf("%.6lX ",raster[y*width+x]);
    printf("\n");
  }

  return(0);
}

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* the pnm file used
P3
3 5
1
1 0 0  0 1 0  0 0 1
1 0 0  0 1 0  0 0 1
1 0 0  1 1 0  1 1 1
0 0 0  0 0 0  0 0 0
1 1 1  1 1 1  1 1 1
*/
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* result
contiguous: 
FFFFFF FFFFFF FFFFFF              // isn't this the last line??
000000 000000 000000              // the RGBA order is right, by the way.
0000FF 00FFFF FFFFFF              
0000FF 00FF00 FF0000 
0000FF 00FF00 FF0000              // The 0000FF should be (0,0)
*/
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

------

:) BitNet,InterNet:                        Fidonet:                         :P
:>   h9118101@{hkuxa,hkusub,hkueee}.hku.hk   Beta Yip                       :O
:]   {beta,clyip}@sunmp.csd.hku.hk           Moderator of Lyrics Conference :D
:9                                             in Funny World BBS           :*