screen-save with colormap and RGB modes

Thant Tessman thant at horus.sgi.com
Tue Oct 31 05:21:01 AEST 1989


In article <3599 at amelia.nas.nasa.gov>, hultquis at orville.nas.nasa.gov (Jeff P.M. Hultquist) writes:
> I am using a Personal Iris running IRIX 3.1 ...
> 
> For making screen-dumps, I have been using the program 'scrsave' 
> (which is in '/usr/people/4Dgifts/...').  This works fine for
> windows which are in colormap mode, but it doesn't grab the proper
> color-components for windows which are using RGBmode.  The source
> for 'scrsave.c' contains a call to 'gl_readscreen', which appears 
> to be intended to handle pixels regardless of their display mode.
> This function is not listed in the man pages; however, it *is* in
> '/usr/lib/libgl.a'.
> 
> So ... what gives? 
> 
>    * Can I find the displayed color of a pixel regardless
> 	of its display mode?
>    * If so, how?
>    * If gl_readscreen is the right thing to be using for this,
> 	why is my copy broken?  


I don't know a lot about this stuff, but I think that the reason the
source to gl_readscreen isn't available is because it does some hardware
dependent things to determine the graphics mode of the pixels.

I have no idea why your copy doesn't work.  Does the scrsave in 
/usr/sbin work?

(Stuff beginning with 'gl_' is not guaranteed to work from platform to 
platform or even from release to release, and is not recommended for use.)

Here's the 3.2 source for scrsave (from 4Dgifts):  (Is it different?)

thant

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

/*
 *	scrsave - 
 *		Save a part of the screen in an image file.
 *
 *			Paul Haeberli - 1988
 */
#include "gl.h"
#include <stdio.h>
#include "port.h"
#include "image.h"

char rbuf[2048];
char gbuf[2048];
char bbuf[2048];
short rs[2048];
short gs[2048];
short bs[2048];

main(argc,argv)
int argc;
char **argv;
{
    int i, y, gotfirst;
    int x1, x2, y1, y2;

    if(argc!=2 && argc!=6) {
	printf("usage: scrsave outimage [x1 x2 y1 y2]\n");
	exit(1);
    } 
    if(argc==6) {
	x1 = atoi(argv[2]);
	x2 = atoi(argv[3]);
	y1 = atoi(argv[4]);
	y2 = atoi(argv[5]);
    } else {
	x1 = 0;
	x2 = XMAXSCREEN;
	y1 = 0;
	y2 = YMAXSCREEN;
    }
    foreground();
    noport();
    winopen("scrsave");
    savescreen(argv[1],x1,x2,y1,y2);
}

savescreen(name,x1,x2,y1,y2)
char *name;
int x1, x2, y1, y2;
{
    IMAGE *oimage;
    int xsize, ysize;
    int xorg, yorg;
    int temp, y, i;
    int pos, togo, n;

    xorg = MIN(x1,x2);
    yorg = MIN(y1,y2);
    if(xorg<0)
       xorg = 0;
    if(yorg<0)
       yorg = 0;
    xsize = ABS(x2-x1);
    ysize = ABS(y2-y1);
    if((xorg+xsize)>XMAXSCREEN)
	xsize = XMAXSCREEN-xorg;
    if((yorg+ysize)>YMAXSCREEN)
	ysize = YMAXSCREEN-yorg;
    xsize++;
    ysize++;
    oimage = iopen(name,"w",RLE(1),3,xsize,ysize,3);
    wmplanes();
    screenspace();
    for(y=0; y<ysize; y++) {
#define READSCREENBROKEN
#ifdef READSCREENBROKEN
	togo = xsize;
	pos = 0;
	while(togo) {
	    n = togo;
	    if(n>256)
		n = 256;
	    cmov2i(xorg+pos,yorg+y);
	    gl_readscreen(n,rbuf+pos,gbuf+pos,bbuf+pos);
	    pos += n;
	    togo -= n;
	}
#else
	cmov2i(xorg,yorg+y);
	gl_readscreen(xsize,rbuf,gbuf,bbuf);
#endif
	ctos(rbuf,rs,xsize);
	ctos(gbuf,gs,xsize);
	ctos(bbuf,bs,xsize);
	putrow(oimage,rs,y,0);
	putrow(oimage,gs,y,1);
	putrow(oimage,bs,y,2);
    }
    iclose(oimage);
}


--
There are 336 dimples on the standard golf ball.



More information about the Comp.sys.sgi mailing list