home *** CD-ROM | disk | FTP | other *** search
- /* *****************************************************************************
- *
- * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- *
- ***************************************************************************** */
- /*
- * ipaint - mouse images around on the screen
- */
-
- #include <stdio.h>
- #include <sys/types.h>
- #include <dirent.h>
- #include <gl.h>
- #include <gl/image.h>
- #include <device.h>
-
-
- unsigned short ir[1280], /* for reading the image file */
- ig[1280],
- ib[1280];
-
- int Haveimage; /* we have an image file loaded */
-
- int x_size, y_size, n_total; /* dimensions of current image */
-
- int *image; /* ptrs to pixel data areas for current image */
- /*
- * image-file handling
- *
- * each available image file is described by a struct img_file.
- * these structs are kept in a linked list.
- */
-
- struct img_file {
- char *name;
- int *rgb;
- int xsize, ysize;
- };
-
- struct img_file *file;
-
-
- char *Progname;
-
- extern char *malloc();
- extern long time();
- extern char *optarg;
- extern int optind;
-
-
- readrgb(char *filename)
- {
- IMAGE *image_str;
- short *c8, *c12;
- int *rgb;
- int y;
- int modesave;
-
- Haveimage = 0;
-
- image = NULL;
-
- if ( (image_str = iopen(filename,"r")) == NULL ) {
- fprintf(stderr, "ipaint: can't open input file %s\n", filename);
- system("inform 'can not open input file chosen'");
- /* black_screen(); */
- return;
- }
- if ( image_str->zsize < 3 ) {
- fprintf(stderr, "ipaint: input image is not a color image %s\n",filename);
- system("inform 'input image is not a color image'");
- /* black_screen(); */
- return;
- }
-
- x_size = image_str->xsize;
- y_size = image_str->ysize;
- n_total = x_size * y_size;
-
- image = (int *) malloc(x_size*y_size*sizeof(int));
- rgb = image;
-
- for (y = 0; y < y_size; y++) {
- getrow(image_str, ir, y, 0);
- getrow(image_str, ig, y, 1);
- getrow(image_str, ib, y, 2);
-
- rgb_to_packed_rgb(ir, ig, ib, rgb, x_size);
-
- rgb += x_size;
- }
-
- /* newmode(modesave); */
-
- Haveimage = 1;
- iclose(image_str);
- } /* load file */
-
-
- rgb_to_packed_rgb(rp, gp, bp, ip, n)
- unsigned short *rp, *gp, *bp;
- int *ip;
- int n;
- {
- while (n--)
- *ip++ = (0<<24) | ((*bp++)<<16) | ((*gp++)<<8) | *rp++;
- }
-
-