Example #1
0
void SRGP_loadBitmapPattern (int pattern_id, char *data)
{
   register i,j;


   DEBUG_AIDS{
      SRGP_trace (SRGP_logStream, "SRGP_loadBitmapPattern %d %x\n", 
		  pattern_id, data);
      srgp_check_system_state();
      LeaveIfNonFatalErr();
   }

#ifdef X11
   /* CREATE THE BITMAP (if not already) */
   if (NULL == srgp__bitmapPatternTable[pattern_id]) 
      srgp__bitmapPatternTable[pattern_id] = 
	 XCreatePixmap
	    (srgpx__display, srgp__canvasTable[0].drawable.win, 8, 8,
	     1);

   if (NULL == srgp__bitmapPatternTable[pattern_id]) {
      SRGP__error (ERR_PATTERN_ALLOCATION);
      return;
   }

   /* PAINT THE PIXELS */
   for (i=0; i<8; i++)
      for (j=7; j>=0; j--)
	 XPutPixel (ximage_bit, i,j, (data[i]&(1<<j))?XBLACK:XWHITE);


   /* PUT THE XIMAGE INTO THE BITMAP */
   XPutImage (srgpx__display,
	      srgp__bitmapPatternTable[pattern_id],
	      putimagegc_bit,
	      ximage_bit,
	      0,0, 0,0, 8,8);
#endif

#ifdef THINK_C
   memcpy (srgp__bitmapPatternTable[pattern_id], data, 8);
#endif
}
Example #2
0
void SRGP_loadColorTable
(int startentry, int count,
 unsigned short *redi,
 unsigned short *greeni,
 unsigned short *bluei)
{
    register int i, j;
    RGBColor rgb;
    ReqListRec **rl;
    CTabHandle ctab;


    DEBUG_AIDS{
        SRGP_trace (SRGP_logStream, "SRGP_loadColorTable  %d  %d  %x %x %x\n",
        startentry, count, redi, greeni, bluei);

        /* PERFORM CHECKING LEGALITY OF THE RANGE OF INDICES. */
        srgp_check_pixel_value (startentry, "start");
        srgp_check_pixel_value (startentry+count-1, "end");
        LeaveIfNonFatalErr();
    }

#ifdef COLOR_QUICKDRAW
    InitMacColorTable (startentry, startentry+count-1, &ctab);

    for (i=startentry,j=0; j<count; i++,j++) {
        rgb.red = redi[j];
        rgb.green = greeni[j];
        rgb.blue = bluei[j];
        (**srgpmac__applctab).ctTable[i].rgb = rgb;
        (**ctab).ctTable[j].rgb = rgb;
    }

    InitReqList (startentry, startentry+count-1, &rl);
    RestoreEntries (ctab, NULL, *rl);
    DisposHandle (rl);
    DisposHandle (ctab);
#endif
}
Example #3
0
void SRGP_loadPixmapPattern (int pattern_id, int *data)
{
   register i,j;


   DEBUG_AIDS{
      SRGP_trace (SRGP_logStream, "SRGP_loadPixmapPattern %d %x\n", 
		  pattern_id, data);
      srgp_check_system_state();
      LeaveIfNonFatalErr();
   }

   /* CREATE THE PIXMAP (if not already) */
   if (NULL == srgp__pixmapPatternTable[pattern_id]) 
      srgp__pixmapPatternTable[pattern_id] = 
	 XCreatePixmap
	    (srgpx__display, srgp__canvasTable[0].drawable.win, 8, 8,
	     srgp__available_depth);
   if (NULL == srgp__pixmapPatternTable[pattern_id]) {
      SRGP__error (ERR_PATTERN_ALLOCATION);
      return;
   }

   /* PAINT THE PIXELS */
   for (i=0; i<8; i++)
      for (j=7; j>=0; j--)
 	 XPutPixel (ximage_pix, i,j, XCOLOR(COLORINDEX(data[(i<<3)+j])));


   /* PUT THE XIMAGE INTO THE PIXMAP */
   XPutImage (srgpx__display,
	      srgp__pixmapPatternTable[pattern_id],
	      putimagegc_pix,
	      ximage_pix,
	      0,0, 0,0, 8,8);
}