Skip to content

Commit 5fc6773

Browse files
committed
Added readdisplay() routine
1 parent 852cc22 commit 5fc6773

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

Modules/cstubs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,35 @@ gl_lrectread(self, args)
657657
return parray;
658658
}
659659

660+
% readdisplay
661+
662+
static object *
663+
gl_readdisplay(self, args)
664+
object *self;
665+
object *args;
666+
{
667+
short x1, y1, x2, y2;
668+
unsigned long *parray, hints;
669+
long size, size_ret;
670+
object *rv;
671+
672+
if ( !getargs(args, "hhhhl", &x1, &y1, &x2, &y2, &hints) )
673+
return 0;
674+
size = (long)(x2+1-x1) * (long)(y2+1-y1);
675+
rv = newsizedstringobject((char *)NULL, size*sizeof(long));
676+
if ( rv == NULL )
677+
return NULL;
678+
parray = (unsigned long *)getstringvalue(rv);
679+
size_ret = readdisplay(x1, y1, x2, y2, parray, hints);
680+
if ( size_ret != size ) {
681+
printf("gl_readdisplay: got %d pixels, expected %d\n",
682+
size_ret, size);
683+
err_setstr(RuntimeError, "readdisplay returned unexpected length");
684+
return NULL;
685+
}
686+
return rv;
687+
}
688+
660689
/* Desperately needed, here are tools to compress and decompress
661690
the data manipulated by lrectread/lrectwrite.
662691

0 commit comments

Comments
 (0)