/** * Restore the screen overwritten by the cursor. * * @param psd Drawing surface. * @return 1 iff the cursor was visible, else <= 0 */ int GdHideCursor(PSD psd) { MWPIXELVAL * saveptr; MWCOORD x, y; int oldmode; int prevcursor = curvisible; if(curvisible-- <= 0) return prevcursor; oldmode = gr_mode; gr_mode = MWROP_COPY; saveptr = cursavbits; for (y = cursavy; y <= cursavy2; y++) { for (x = cursavx; x <= cursavx2; x++) { if(x >= 0 && x < psd->xvirtres && y >= 0 && y < psd->yvirtres) { psd->DrawPixel(psd, x, y, *saveptr++); } } } gr_mode = oldmode; return prevcursor; }
/* * Generalized low level bitmap output routine, called * only if no clipping is required. Only the set bits * in the bitmap are drawn, in the foreground color. */ void gen_drawbitmap(PSD psd,COORD x, COORD y, COORD width, COORD height, const IMAGEBITS *table, PIXELVAL fgcolor) { COORD minx; COORD maxx; IMAGEBITS bitvalue; /* bitmap word value */ int bitcount; /* number of bits left in bitmap word */ minx = x; maxx = x + width - 1; bitcount = 0; while (height > 0) { if (bitcount <= 0) { bitcount = IMAGE_BITSPERIMAGE; bitvalue = *table++; } if (IMAGE_TESTBIT(bitvalue)) psd->DrawPixel(psd, x, y, fgcolor); bitvalue = IMAGE_SHIFTBIT(bitvalue); --bitcount; if (x++ == maxx) { x = minx; ++y; --height; bitcount = 0; } } }
/** * Draw the mouse pointer. Save the screen contents underneath * before drawing. Returns previous cursor state. * * @param psd Drawing surface. * @return 1 iff the cursor was visible, else <= 0 */ int GdShowCursor(PSD psd) { MWCOORD x; MWCOORD y; MWPIXELVAL * saveptr; MWIMAGEBITS * cursorptr; MWIMAGEBITS * maskptr; MWIMAGEBITS curbit, cbits = 0, mbits = 0; MWPIXELVAL oldcolor; MWPIXELVAL newcolor; int oldmode; int prevcursor = curvisible; if(++curvisible != 1) return prevcursor; oldmode = gr_mode; gr_mode = MWROP_COPY; saveptr = cursavbits; cursavx = curminx; cursavy = curminy; cursavx2 = curmaxx; cursavy2 = curmaxy; cursorptr = cursorcolor; maskptr = cursormask; /* * Loop through bits, resetting to firstbit at end of each row */ curbit = 0; for (y = curminy; y <= curmaxy; y++) { if (curbit != MWIMAGE_FIRSTBIT) { cbits = *cursorptr++; mbits = *maskptr++; curbit = MWIMAGE_FIRSTBIT; } for (x = curminx; x <= curmaxx; x++) { if(x >= 0 && x < psd->xvirtres && y >= 0 && y < psd->yvirtres) { oldcolor = psd->ReadPixel(psd, x, y); if (curbit & mbits) { newcolor = (curbit&cbits)? curbg: curfg; if (oldcolor != newcolor) psd->DrawPixel(psd, x, y, newcolor); } *saveptr++ = oldcolor; } curbit = MWIMAGE_NEXTBIT(curbit); if (!curbit) { /* check > one MWIMAGEBITS wide*/ cbits = *cursorptr++; mbits = *maskptr++; curbit = MWIMAGE_FIRSTBIT; } } } gr_mode = oldmode; return prevcursor; }
/* * Draw the mouse pointer. Save the screen contents underneath * before drawing. Returns previous cursor state. */ int GdShowCursor(PSD psd) { MWCOORD x; MWCOORD y; MWPIXELVAL * saveptr; MWIMAGEBITS * cursorptr; MWIMAGEBITS * maskptr; MWIMAGEBITS curbit, cbits, mbits; MWPIXELVAL oldcolor; MWPIXELVAL newcolor; int oldmode; int prevcursor = curvisible; if(++curvisible != 1) return prevcursor; oldmode = gr_mode; gr_mode = MWMODE_COPY; saveptr = cursavbits; cursavx = curminx; cursavy = curminy; cursavx2 = curmaxx; cursavy2 = curmaxy; cursorptr = cursorcolor; maskptr = cursormask; for (y = curminy; y <= curmaxy; y++) { cbits = *cursorptr++; mbits = *maskptr++; curbit = MWIMAGE_FIRSTBIT; for (x = curminx; x <= curmaxx; x++) { if(x >= 0 && x < psd->xvirtres && y >= 0 && y < psd->yvirtres) { oldcolor = psd->ReadPixel(psd, x, y); if (curbit & mbits) { newcolor = (curbit&cbits)? curbg: curfg; if (oldcolor != newcolor) psd->DrawPixel(psd, x, y, newcolor); } *saveptr++ = oldcolor; } curbit = MWIMAGE_NEXTBIT(curbit); } } gr_mode = oldmode; return prevcursor; }