/* @(#)InvertPseudo.c 1.1 02 Sep 1993 */ /*----------------------------------------------------------------------------- Copyright(C) 1993 , Molecular Structure Group of Biochemestry Dept. at University of California at San Francisco. These coded instructions , statements , and computer programs comprise unpublished proprietary information of the Molecular Structure Group of the Biochemistry Department at University of California at San Francisco , and are protected by Federal copyright law. They may not be disclosed to third parties , copied or duplicated in any form - in whole or in part - without the prior written consent of Molecular Structure Group of Biochemistry Department at University of California at San Francisco. -------------------------------------------------------------------------*/ /* * A simple program to show how to use lut related IWL routines to reverse * IWL's pseudo color LUT */ #include "IWInclude.h" #include /* fprintf, printf, stderr */ #include /* free, malloc */ int main(int argc, char** argv) { int imin, imax, csiz; int* ctab; int* ired; int* igreen; int* iblue; int i; if (IWAttach() == IW_ERROR) { (void) fprintf( stderr, "IWL not running or unable to attach to shared memory; quitting\n" ); return 1; } IWRtSclMinMax(&imin, &imax); csiz = imin + IWRtLutSize() + IW_NUM_COLORS; ctab = (int*) malloc(3 * sizeof(int) * csiz); if (ctab == 0) { (void) fprintf(stderr, "Unable to allocate space for color table\n"); return 1; } ired = ctab; igreen = ctab + csiz; iblue = ctab + csiz * 2; IWRtLut(ired, igreen, iblue); /* Print the components of the graphic colors. */ for (i = imax + 1; i <= imax + IW_NUM_COLORS; ++i) { (void) printf(" rgb= %d %d %d %d\n", i, ired[i], igreen[i], iblue[i]); } /* Reverse the color table. */ for (i = imin; i <= imax + IW_NUM_COLORS; ++i) { ired[i] = 255 - ired[i]; igreen[i] = 255 - igreen[i]; iblue[i] = 255 - iblue[i]; } IWAlLut(ired, igreen, iblue); free(ctab); return 0; }