⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 m124_img.c

📁 与Nucleus Plus配套的图形库
💻 C
📖 第 1 页 / 共 3 页
字号:
	return;
}


/* Function DrawRectEntry1B2_4B blits the image to the memory */
void DrawRectEntry1B2_4B(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 mwRDIM2_4B is a special case optimization for ReadImage,
2/4 bit per pixel, linear memory. */
void mwRDIM2_4B(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 = rdiBmap->pixBits;	/* determine number of bits per pixel */
	if (shfCnt == 2)
	{	/* 2 bpp */
		flipMask = 2;
		firstOffset = 0x03;
	}
	else
	{	/* 4 bpp */
		flipMask = 1;
		firstOffset = 0x01;
	}

	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 = flipMask << 1; */

	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 NotDestSolidImgM2_4B handles memory "not dst" by inverting the
destination first. */
void NotDestSolidImgM2_4B(void)
{
	void InvertDestM2_4B(void);
	void OXADestImgM2_4B(void);

	InvertDestM2_4B();

	OXADestImgM2_4B();	/* fill this rectangle */

	return;
}


/* Function RepDestImgM2_4B sets the destination pixel data with the
source data. */
void RepDestImgM2_4B(void)
{
	int lclByteCnt, lclShift;
	int dstPxShift, srcPxShift, srcShf;
	byte dstPxBit, srcPxBit, srcColr;

	dstPxShift = (dRect.Xmin & firstOffset) * shfCnt;
	srcPxShift = (sRect.Xmin & firstOffset) * shfCnt;
	srcShf = srcPxShift - dstPxShift;

/* BobB 1/15/99 - corrected image shifting */
	if (srcShf < 0) srcShf = -srcShf;

	lclShift = (flipMask << 1);

	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 */
				if (shfCnt == 2)
				{
					dstPxBit = 0xc0;
				}
				else
				{
					dstPxBit = 0xf0;
				}

			}

			srcPxBit = (srcPxBit >> shfCnt);
			if (srcPxBit == 0)
			{	/* advance to next byte */
				srcPtr++;
				if (shfCnt == 2)
				{
					srcPxBit = 0xc0;
				}
				else
				{
					srcPxBit = 0xf0;
				}

			}

		}

		dRect.Ymin++;	/* advance to next row */
		sRect.Ymin++;
	}

	return;
}


/* Function OXADestImgM2_4B sets the destination pixel data based on
the logical function "OR", "XOR" or "AND". */
void OXADestImgM2_4B(void)
{
	int lclByteCnt, lclShift;
	int dstPxShift, srcPxShift, srcShf;
	byte dstPxBit, srcPxBit, srcColr;
	int logFnc;

	dstPxShift = (dRect.Xmin & firstOffset) * shfCnt;
	srcPxShift = (sRect.Xmin & firstOffset) * shfCnt;
	srcShf = srcPxShift - dstPxShift;

/* BobB 1/15/99 - corrected image shifting */
	if (srcShf < 0) srcShf = -srcShf;

	lclShift = (flipMask << 1);
	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 */
				if (shfCnt == 2)
				{
					dstPxBit = 0xc0;
				}
				else
				{
					dstPxBit = 0xf0;
				}
			}

			srcPxBit = (srcPxBit >> shfCnt);
			if (srcPxBit == 0)
			{	/* advance to next byte */
				srcPtr++;
				if (shfCnt == 2)
				{
					srcPxBit = 0xc0;
				}
				else
				{
					srcPxBit = 0xf0;
				}
			}
		}

		dRect.Ymin++;	/* advance to next row */
		sRect.Ymin++;
	}

	return;
}


/* Function mwWRIM1Bit is a special case optimization for 1->1Bit
WriteImage. */
void mwWRIM1Bit(blitRcd *blitRec)
{
	void DrawRectEntry1_1Bit(blitRcd *blitRec);
	int Set_Up_Clip(blitRcd *clipBlit, rect *clipR, int blitMayOverlap,
				int isLine);
    int Blit_Clip_Region(blitRcd *fcRec, rect *fillRect, rect *sRect);
	void nuResume(grafMap *srcBmap);
	void RepDest1M1Bit(void);
	void OXADest1M1Bit(void);
	void SetDestM1Bit(void);
	void NotDestSolid1M1Bit(void);
	void InvertDestM1Bit(void);
	void QuickEnd(void);
	void SetTrans1M1Bit(void);
	void InvertTrans1M1Bit(void);

	rect *rListPtr;	/* list pointer */
	int blitMayOverlap = 0;	/* Set false for region clipping*/
	int isLine = 0;	/* Set false */

	srcImag = (image *) blitRec->blitSmap; 

	if((srcImag->imWidth <= 0) || (srcImag->imHeight <= 0))
		return;

	sRect.Ymin = 0;
/* BobB 10/22/99 - corrected start X
	sRect.Xmin = 0; */
	sRect.Xmin = srcImag->imAlign;
	srcPixBytes = srcImag->imBytes;
	rListPtr =  (rect *) blitRec->blitList;

	dstBmap =  blitRec->blitDmap;
	dstClass = blitRec->blitRop & 0x1f;

	M_PAUSE(dstBmap);

	bkColr = (char) blitRec->blitBack;	/* background color */
	pnColr = (char) blitRec->blitFore;	/* foreground color */

	switch (dstClass)
	{	/* look up the optimization routine */
	  			    /* Memory non-transparent */
	case 0:		/* zREPz   :           src			 */
	case 4:		/* zNREPz  :        (NOT src)		 */
		optPtr = &RepDest1M1Bit;
		break;
	case 1:		/* zORz    :       src OR  dst		 */
	case 2:		/* zXORz   :       src XOR dst		 */
	case 3:		/* zNANDz  :    (NOT src) AND dst	 */
	case 5:		/* zNORz   :    (NOT src) OR  dst	 */
	case 6:		/* zNXORz  :    (NOT src) XOR dst	 */
	case 7:		/* zANDz   :       src AND dst		 */
		optPtr = &OXADest1M1Bit;
		break;
	case 8:		/* zCLEARz :           0's			 */
	case 12:	/* zSETz   :           1's			 */
		optPtr = &SetDestM1Bit;
		break;
	case 9:		/* zORNz   :     src OR  (NOT dst)	 */
	case 11:	/* zANDNz  :     src AND (NOT dst)	 */
	case 13:	/* zNORNz  : (NOT src) OR  (NOT dst) */
	case 15:	/* zNANDNz : (NOT src) AND (NOT dst) */
		optPtr = &NotDestSolid1M1Bit;
		break;
	case 10:	/* zNOPz   :           dst <NOP>	 */
		optPtr = &QuickEnd;
		break;
	case 14:	/* zINVERTz:        (NOT dst)		 */
		optPtr = &InvertDestM1Bit;
		break;
	  			    /* Memory transparent */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -