📄 m124_img.c
字号:
case 16: /* xREPx : !0src */
case 17: /* xORx : !0src OR dst */
case 25: /* xORNx : !0src OR (NOT dst) */
case 28: /* xSETx : 1's */
optPtr = &SetTrans1M1Bit;
break;
case 18: /* xXORx : !0src XOR dst */
case 27: /* xANDNx : !0src AND (NOT dst) */
case 30: /* xINVERTx: (NOT dst) */
optPtr = &InvertTrans1M1Bit;
break;
case 19: /* xNANDx : (NOT !0src) AND dst */
case 20: /* xNREPx : (NOT !0src) */
case 21: /* xNORx : (NOT !0src) OR dst */
case 22: /* xNXORx : (NOT !0src) XOR dst */
case 23: /* xANDx : !0src AND dst */
case 24: /* xCLEARx : 0's */
case 26: /* xNOPx : dst <NOP> */
case 29: /* xNORNx : (NOT !0src) OR (NOT dst) */
case 31: /* xNANDNx : (NOT !0src) AND (NOT dst) */
optPtr = &QuickEnd;
break;
}
/* modify the pen color as necessary */
switch (dstClass)
{
case 3: /* zNANDz */
case 4: /* zNREPz */
case 5: /* zNORz */
case 6: /* zNXORz */
case 13: /* zNORNz */
case 15: /* zNANDNz */
pnColr = ~pnColr; /* this has the effect of notting the
pen color for all operations during this call */
case 0: /* zREPz */
case 1: /* zORz */
case 2: /* zXORz */
case 7: /* zANDz */
case 9: /* zORNz */
case 10: /* zNOPz */
case 11: /* zANDNz */
break;
case 8: /* zCLEARz */
pnColr = 0; /* sets all source bits to 0 */
break;
case 12: /* zSETz */
case 14: /* zINVERTz */
pnColr = (char)-1; /* sets all source bits to 1 */
break;
default: /* all transparent cases */
break;
}
shfCnt = 1;
flipMask = 3;
shiftMask = 0x80;
firstOffset = 0x07;
/* BobB 10/15/99 - corrected pen color
pnColr = pnColr & 0x01; */
/* set up clipping */
if (Set_Up_Clip(blitRec, &cRect, blitMayOverlap, isLine))
goto WI1_RTN;
dRect = *rListPtr;
/* See if the destination is too wide */
if((dRect.Xmax - dRect.Xmin) > srcImag->imWidth)
dRect.Xmax = dRect.Xmin + srcImag->imWidth;
/* sXmax not adjusted because not used */
/* See if the destination is too high */
if((dRect.Ymax - dRect.Ymin) > srcImag->imHeight)
dRect.Ymax = dRect.Ymin + srcImag->imHeight;
/* sYmax not adjusted because not used */
/* do we need to worry about clipping */
if(clipToRectFlag != 0)
{
if (dRect.Xmin < cRect.Xmin)
{ /* Reset src & dst Xmin clip limit */
sRect.Xmin -= (dRect.Xmin - cRect.Xmin);
dRect.Xmin = cRect.Xmin;
}
if (dRect.Ymin < cRect.Ymin)
{ /* Reset src & dst Ymin clip limit */
sRect.Ymin -= (dRect.Ymin - cRect.Ymin);
dRect.Ymin = cRect.Ymin;
}
if (dRect.Xmax > cRect.Xmax)
{ /* Reset dst Xmax clip limit */
dRect.Xmax = cRect.Xmax;
}
if (dRect.Ymax > cRect.Ymax)
{ /* Reset dst Ymax clip limit */
dRect.Ymax = cRect.Ymax;
}
if ((dRect.Xmin >= dRect.Xmax) || (dRect.Ymin >= dRect.Ymax))
return;
/* do we need to worry about region clipping? */
if (clipToRegionFlag != 0)
{ /* yes, go do it */
FillDrawer = &DrawRectEntry1_1Bit;
Blit_Clip_Region(blitRec, &dRect, &sRect);
goto WI1_RTN;
}
}
DrawRectEntry1_1Bit(blitRec);
WI1_RTN:
nuResume(dstBmap);
return;
}
/* Function DrawRectEntry1_1Bit blits the image to the memory */
void DrawRectEntry1_1Bit(blitRcd *blitRec)
{
lineCntM1 = dRect.Ymax - dRect.Ymin - 1;
dstBgnByte = (dRect.Xmin >> flipMask);
/* BobB 6/14/99 - added the following line to correct write addressing */
srcBgnByte = (sRect.Xmin >> 3);
byteCntM1 = dRect.Xmax - dRect.Xmin - 1;
/* BobB 6/14/99 - corrected the following lines for write addressing
srcNextRow = srcPixBytes - ((byteCntM1 + 1) >> 3);
srcPtr = (byte *) (srcImag->imData); */
srcNextRow = srcPixBytes - ((sRect.Xmin + byteCntM1 + 1) >> 3)
+ srcBgnByte;
srcPtr = (byte *) (srcImag->imData + (sRect.Ymin * srcPixBytes)
+ srcBgnByte);
optPtr(); /* blit the rectangle */
return;
}
/* Function mwRDIM1Bit is a special case optimization for ReadImage,
2/4 bit per pixel, linear memory. */
void mwRDIM1Bit(grafMap * rdiBmap, image *dstImage, int gblYmax, int gblXmax,
int gblYmin, int gblXmin)
{
void nuResume(grafMap *dstBmap);
int srcRowBytes ;/*# of bytes across a source bitmap row */
int dstRowBytes ;/* # of bytes across an dstImage row */
int cXmax,cYmax ;/* bitmap limits */
short grafErrValue, tmpYmin;
long *srcMapTable;
byte *dstPtrSav;
/* BobB 1/15/99 - corrected byte count */
int count;
gblXmax--;
gblYmax--;
M_PAUSE(rdiBmap);
shfCnt = 1;
flipMask = 3;
firstOffset = 0x07;
srcRowBytes = rdiBmap->pixBytes; /* # of byte across the source */
srcMapTable = (long *)rdiBmap->mapTable[0]; /* store mapTable[0]
pointer locally */
/* get the source bitmap's limits */
cXmax = rdiBmap->pixWidth - 1;
cYmax = rdiBmap->pixHeight - 1;
/* Initialize dstImage header and destination copy parameters */
dstImage->imFlags = 0; /* assume no span segment */
dstImage->imPlanes = 1; /* always plane # 1 */
/* BobB 1/5/99 - corrected the following line to get the number of bits per pixel
dstImage->imBits = dstImage->imBits;*/ /* # bits per pixel */
dstImage->imBits = rdiBmap->pixBits; /* # bits per pixel */
dstImage->imHeight = gblYmax - gblYmin + 1;
dstImage->imAlign = gblXmin & firstOffset;
dstImage->imWidth = gblXmax - gblXmin + 1;
dstImage->imBytes = (dstImage->imWidth + dstImage->imAlign) >> flipMask;
dstRowBytes = dstImage->imBytes;
dstPtr = (byte *)((long) &dstImage->imData[0]);
if((dstImage->imWidth > 0x7FFF) || (dstImage->imHeight > 0x7FFF))
{
grafErrValue = c_ReadImag + c_OfloRect;
rdiBmap->cbPostErr(grafErrValue);
dstImage->imWidth = 0;
dstImage->imHeight = 0;
dstImage->imBytes = 0;
goto RI_RTN;
}
if((dstImage->imWidth < 0) || (dstImage->imHeight < 0))
{
grafErrValue = c_ReadImag + c_NullRect;
rdiBmap->cbPostErr(grafErrValue);
dstImage->imWidth = 0;
dstImage->imHeight = 0;
dstImage->imBytes = 0;
goto RI_RTN;
}
if((dstImage->imWidth == 0) || (dstImage->imHeight == 0))
{
dstImage->imWidth = 0;
dstImage->imHeight = 0;
dstImage->imBytes = 0;
goto RI_RTN;
}
/* Now clip to the source bitmap */
/* check that gblXmin is not off bitmap */
if(gblXmin < 0)
{
dstPtr -= (gblXmin + firstOffset) >> flipMask;
gblXmin = 0;
}
/* Check that gblYmin is not off bitmap */
if(gblYmin < 0)
{
dstPtr = (byte *) (((long) dstPtr) + (dstRowBytes *
(-gblYmin)));
gblYmin = 0;
}
/* Check that gblYmax is not off bitmap */
if(cYmax < gblYmax) gblYmax = cYmax;
/* Check that gblXmax is not off bitmap */
if(cXmax < gblXmax) gblXmax = cXmax;
/* Now set the horizontal and vertical */
byteCntM1 = (gblXmax - gblXmin + dstImage->imAlign) >> flipMask;
if(byteCntM1 < 0) goto RI_RTN;
lineCntM1 = (gblYmax - gblYmin);
if(lineCntM1 < 0) goto RI_RTN;
tmpYmin = gblYmin;
/* BobB 1/15/99 - corrected byte count
flipMask = 8; */
while(lineCntM1-- >= 0)
{
/* point to row table entry for the source row */
/* BobB 1/15/99 - corrected byte count
srcPtr = (byte *) *(srcMapTable + (tmpYmin * srcRowBytes))
+ gblXmin; */
srcPtr = (byte *) *(srcMapTable + tmpYmin) + (gblXmin >> flipMask);
dstPtrSav = dstPtr; /* save for later */
/* BobB 1/15/99 - corrected byte count
while(byteCntM1 >= 0) */
for (count = 0; count <= byteCntM1; count++)
{
*dstPtr++ = *srcPtr++;
/* BobB 1/15/99 - corrected byte count
byteCntM1 -= flipMask; */
}
dstPtr = dstPtrSav + dstRowBytes;
tmpYmin++;
}
RI_RTN:
nuResume(rdiBmap);
return;
}
/* Function NotDestSolidImgM1Bit handles memory "not dst" by inverting the
destination first. */
void NotDestSolidImgM1Bit(void)
{
void InvertDestM1Bit(void);
void OXADestImgM1Bit(void);
InvertDestM1Bit();
OXADestImgM1Bit(); /* fill this rectangle */
return;
}
/* Function RepDestImgM1Bit sets the destination pixel data with the
source data. */
void RepDestImgM1Bit(void)
{
int lclByteCnt, lclShift;
int dstPxShift, srcPxShift, srcShf;
byte dstPxBit, srcPxBit, srcColr;
dstPxShift = (dRect.Xmin & firstOffset);
srcPxShift = (sRect.Xmin & firstOffset);
srcShf = srcPxShift - dstPxShift;
/* BobB 1/15/99 - corrected image shifting */
if (srcShf < 0) srcShf = -srcShf;
lclShift = 8;
while (lineCntM1-- >= 0)
{ /* for each row */
dstPtr = (byte *) (*(dstBmap->mapTable[0] + dRect.Ymin))
+ dstBgnByte;
srcPtr = (byte *) (srcImag->imData + (sRect.Ymin * srcPixBytes))
+ srcBgnByte;
lclByteCnt = byteCntM1;
dstPxBit = (byte) (shiftMask >> dstPxShift);
srcPxBit = (byte) (shiftMask >> srcPxShift);
while (lclByteCnt-- >= 0)
{ /* for each byte in the row */
srcColr = (*srcPtr ^ pnColr) & srcPxBit;
/* BobB 1/15/99 - corrected image shifting
if (srcShf < 0) srcColr = (srcColr >> -srcShf);
if (srcShf > 0) srcColr = (srcColr << srcShf); */
if (dstPxBit < srcPxBit) srcColr = (srcColr >> srcShf);
if (dstPxBit > srcPxBit) srcColr = (srcColr << srcShf);
*dstPtr = (*dstPtr & ~dstPxBit) | srcColr;
dstPxBit = (dstPxBit >> shfCnt);
if (dstPxBit == 0)
{ /* advance to next byte */
dstPtr++;
/* now check for high speed middle blit */
if (srcShf == 0)
{ /* yes */
while (lclByteCnt >= lclShift)
{ /* for each byte in the row */
srcPtr++;
*dstPtr = pnColr ^ *srcPtr;
dstPtr++;
lclByteCnt -= lclShift;
}
}
/* do rest of data */
dstPxBit = 0x80;
}
srcPxBit = (srcPxBit >> shfCnt);
if (srcPxBit == 0)
{ /* advance to next byte */
srcPtr++;
srcPxBit = 0x80;
}
}
dRect.Ymin++; /* advance to next row */
sRect.Ymin++;
}
return;
}
/* Function OXADestImgM1Bit sets the destination pixel data based on
the logical function "OR", "XOR" or "AND". */
void OXADestImgM1Bit(void)
{
int lclByteCnt, lclShift;
int dstPxShift, srcPxShift, srcShf;
byte dstPxBit, srcPxBit, srcColr;
int logFnc;
dstPxShift = (dRect.Xmin & firstOffset);
srcPxShift = (sRect.Xmin & firstOffset);
srcShf = srcPxShift - dstPxShift;
/* BobB 1/15/99 - corrected image shifting */
if (srcShf < 0) srcShf = -srcShf;
lclShift = 8;
logFnc = (dstClass & 3); /* only two lower bits needed */
while (lineCntM1-- >= 0)
{ /* for each row */
dstPtr = (byte *) (*(dstBmap->mapTable[0] + dRect.Ymin))
+ dstBgnByte;
srcPtr = (byte *) (srcImag->imData + (sRect.Ymin * srcPixBytes))
+ srcBgnByte;
lclByteCnt = byteCntM1;
dstPxBit = (byte) (shiftMask >> dstPxShift);
srcPxBit = (byte) (shiftMask >> srcPxShift);
while (lclByteCnt-- >= 0)
{ /* for each byte in the row */
srcColr = (*srcPtr ^ pnColr) & srcPxBit;
/* BobB 1/15/99 - corrected image shifting
if (srcShf < 0) srcColr = (srcColr >> -srcShf);
if (srcShf > 0) srcColr = (srcColr << srcShf); */
if (dstPxBit < srcPxBit) srcColr = (srcColr >> srcShf);
if (dstPxBit > srcPxBit) srcColr = (srcColr << srcShf);
switch (logFnc)
{
case 0: /* can't happen */
case 1: /* "OR" */
*dstPtr = *dstPtr | srcColr;
break;
case 2: /* "XOR" */
*dstPtr = *dstPtr ^ srcColr;
break;
case 3: /* "AND" */
*dstPtr = *dstPtr & (~dstPxBit | (dstPxBit & srcColr));
break;
}
dstPxBit = (dstPxBit >> shfCnt);
if (dstPxBit == 0)
{ /* advance to next byte */
dstPtr++;
/* now check for high speed middle blit */
if (srcShf == 0)
{ /* yes */
while (lclByteCnt >= lclShift)
{ /* for each byte in the row */
srcPtr++;
srcColr = pnColr ^ *srcPtr;
switch (logFnc)
{
case 0: /* can't happen */
case 1: /* "OR" */
*dstPtr = *dstPtr | srcColr;
break;
case 2: /* "XOR" */
*dstPtr = *dstPtr ^ srcColr;
break;
case 3: /* "AND" */
*dstPtr = *dstPtr & (~dstPxBit | (dstPxBit & srcColr));
break;
}
dstPtr++;
lclByteCnt -= lclShift;
}
}
/* do rest of data */
dstPxBit = 0x80;
}
srcPxBit = (srcPxBit >> shfCnt);
if (srcPxBit == 0)
{ /* advance to next byte */
srcPtr++;
srcPxBit = 0x80;
}
}
dRect.Ymin++; /* advance to next row */
sRect.Ymin++;
}
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -