delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/14/18:35:58

From: gip AT ino DOT it (GianPiero Puccioni)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: GRX
Date: 14 Jan 1997 10:15:00 GMT
Organization: Istituto Nazionale di Ottica-ITALY
Lines: 97
Message-ID: <5bfmb4$ffq@serra.unipi.it>
References: <5b8icg$ma7 AT news DOT interlog DOT com>
NNTP-Posting-Host: fox.ino.it
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Gautam N. Lad (gautam AT interlog DOT com) wrote:
> Hi,
> Is there a function that will allow me to store an image
> in a buffer, and then later display it?
> 
> I want something similar to Turbo C's getimage() and putimage(),
> but I want it in the GRX format.
> 
> I think I read something about Bliting, and even tried to understand
> the BLITTEST.C program, but had a hard time understanding it.
> 
> All I want is to get an image from X,Y with a width (W) and height (H)
> and a pointer to a buffer (void *buffer).  This is what I know
> in Turbo C.
> 

I had the same problem and the only way of doing this was to write a
couple of functions to do this. I'll attach them at the end, but be warned
that as far as I know they work ONLY with GRX 1.03 (and that means don't
work with DGJPP 2), as most of the functions used are not in GRX20. By the
way is there a new version? Or some news about it? I am stuck with version
1 exactly for this reason, I use those functions a lot.
 
The functions are for a 256 color graphic mode but I suppose you can
modify them for different modes.

> Bye!
> ****************************************************
> * Gautam N. Lad                                    *


Ciao,
           GianPiero

-- 
*  Istituto Nazionale di Ottica                        GianPiero Puccioni  *
*  Largo E.Fermi 6                               E-Mail :  gip AT fox DOT ino DOT it  *
*  I-50125  Firenze - ITALY    =>this space intentionally left non-blank<= *

---------------------------------------------------------------------------
#include <grx.h>
#define NULL 0
/***********************************************/
/* put an Array of unsigned char on the display */
/***********************************************/
void PutBlock(unsigned char *array,int xst,int yst,int xdim,int ydim,int *col)
/*
  Parameters:

      array[]     =>    image to be displayed
      xst, yst    =>    coordinate of destination (top left point)
      xdim ydim   =>    dimensions of the image
      col[N+1]    =>    LUT for color transformation
                        col[0] = N =number of colors to be used
                        col[1] <-> col[N] to what color each pixel value
                        has to be mapped. A 256 color linear map
                        can be created with
                             col[0]=256;
                             for (i=0;i<256;i++)
                               col[i+1]=i;
*/
{
GrContext *d,*s;
GrPattern *p;
s=GrSaveContext(NULL);
d=GrCreateContext(xdim,ydim,NULL,NULL);
GrSetContext(d);
p=GrBuildPixmap(array,xdim,ydim,col);
GrPatternFilledBox(0,0,xdim-1,ydim-1,p);
GrDestroyPattern(p);
GrSetContext(s);
GrBitBlt(s,xst,yst,d,0,0,xdim-1,ydim-1,GrWRITE);
GrDestroyContext(d);
GrDestroyContext(s);
}
---------------------------------------------------------------------------
#include <grx.h>

/**********************************************************/
/* get a block from the display and puts it in an Array   */
/**********************************************************/
void GetBlock(unsigned char *array,int xst,int yst,int xdim,int ydim)
/*
  Parameters:

      array[]         image to be displayed
      xst, yst        coordinate of area to capture (top left point)
      xdim ydim       dimensions of the image
*/
{
register int i,j;
for(i=0;i<xdim;i++)
  for(j=0;j<ydim;j++)
   array[i+j*xdim]=GrPixel(i+xst,j+yst);
}

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019