Status: Read
Received: from [207.113.13.68] by phillip.cerious.com (NTMail 3.03.0017/7.aaxh) with ESMTP id pcrews for <pcrews@cerious.com>; Thu, 15 Jul 1999 20:14:49 -0400
Received: from localhost (bin@localhost)
	by gate7.olympiakos.com (8.8.7/8.8.7) with SMTP id TAA19782;
	Thu, 15 Jul 1999 19:59:59 -0400
Received: by gate7.olympiakos.com (bulk_mailer v1.9); Thu, 15 Jul 1999 19:59:05 -0400
Received: (from majordom@localhost)
	by gate7.olympiakos.com (8.8.7/8.8.7) id TAA19760
	for tiff-outgoing; Thu, 15 Jul 1999 19:59:05 -0400
X-Authentication-Warning: gate7.olympiakos.com: majordom set sender to owner-tiff@olympiakos.com using -f
Received: from mail2.imation.com (mail2.imation.com [207.242.212.137])
	by gate7.olympiakos.com (8.8.7/8.8.7) with SMTP id TAA19757
	for <tiff@olympiakos.com>; Thu, 15 Jul 1999 19:59:03 -0400
Received: by mail2.imation.com(Lotus SMTP MTA v4.6.5  (863.2 5-20-1999))  id 862567AF.0083966D ; Thu, 15 Jul 1999 18:57:17 -0500
X-Lotus-FromDomain: IMATION
From: "Eric B. Middlecamp" <ebmiddlecamp@imation.com>
To: TIFF Mailing List <tiff@olympiakos.com>
Message-ID: <862567AF.0083952D.00@mail2.imation.com>
Date: Thu, 15 Jul 1999 18:47:23 -0500
Subject: RGB Gradient Code, adapted from Andreas Neumann
Mime-Version: 1.0
Content-type: text/plain; charset=us-ascii
Content-Disposition: inline
Sender: owner-tiff@olympiakos.com



I made a simple extension to Andreas Neumann's gradient code,
(see
http://www.gis.univie.ac.at/strv/strv/leute/andi/computer/graphics/raster-formats/example_tiff_main.html)
but the output TIFF image has some odd contamination. Looking at the
image, you wouldn't be able to tell -- however a histogram reveals that
some levels are omitted and others are doubled.

Has anyone else experienced bizarre anomalies like this?

Thanks,
Eric Middlecamp

// ======================================================

#include "tiffio.h"

void RGBGradient( char *tiff_fname )
{
     unsigned char color_ptr[256*3];
     int i, j;

     TIFF* tif = TIFFOpen(tiff_fname , "w");
     if (tif == NULL) {
          return;
     }
     TIFFSetField(tif, TIFFTAG_IMAGEWIDTH,         256);
     TIFFSetField(tif, TIFFTAG_IMAGELENGTH,        256);
     TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE,      8);
     TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL,    3);
     TIFFSetField(tif, TIFFTAG_PHOTOMETRIC,        PHOTOMETRIC_RGB);
     TIFFSetField(tif, TIFFTAG_PLANARCONFIG,            PLANARCONFIG_CONTIG);
     TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP,  1);

     for (i = 0; i < 256; i++) {
          for (j = 0; j < 256; j++) {
               color_ptr[j*3+0] = i;
               color_ptr[j*3+1] = i;
               color_ptr[j*3+2] = i;
          }
          TIFFWriteScanline(tif, color_ptr, i);
     }

     TIFFFlushData(tif);
     TIFFClose(tif);
}

// ======================================================


