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

📄 bits7.c

📁 nucleus 文件系统,内核和彩色图形系统,在小系统上非常好用
💻 C
📖 第 1 页 / 共 2 页
字号:
/*************************************************************************/
/*                                                                       */
/*         Copyright (c) 1997 - 1999 Accelerated Technology, Inc.        */
/*                                                                       */
/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the      */
/* subject matter of this material.  All manufacturing, reproduction,    */
/* use, and sales rights pertaining to this subject matter are governed  */
/* by the license agreement.  The recipient of this software implicitly  */
/* accepts the terms of the license.                                     */
/*                                                                       */
/*************************************************************************/

/*************************************************************************/
/*                                                                       */
/* FILE NAME                                            VERSION          */
/*                                                                       */
/*      BITS7.c                                          1.9             */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*      All                                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This file contains the ZOOMBLIT function.                        */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*      Robert G. Burrill, Accelerated Technology, Inc.                  */
/*                                                                       */
/* DATA STRUCTURES                                                       */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* FUNCTIONS                                                             */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* DEPENDENCIES                                                          */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* HISTORY                                                               */
/*                                                                       */
/*         NAME            DATE                    REMARKS               */
/*                                                                       */
/*		   BobB			  5/5/98		Corrected to get rid of compiler */
/* warnings                                                              */
/*         BobB          11/4/99        Corrected for modified variables */
/*                                                                       */
/*************************************************************************/

#include "meta_wnd.h"
#include "metconst.h"    /* MetaWINDOW Constant & Stucture Definitions */
#include "metports.h"    /* MetaWINDOW Port & Bitmap Definitions */
#include "grafdata.h"


/* Function ZOOMBLIT tranfers data between two different sized rectangles.
As ZoomBlit() uses getPixel & setpixel/fill primitives, different grafMap
color depths are OK.

A fixed point value is used to avoid accumulated coordinate errors, and
output coordinates are rounded down when drawn.

ZoomBlit does 1-n color translation, based on the target grafPort's
pen & backColor. As usual, the targets, clipArea, rasterOp, mask
etc. are used (& honored)

When scaling down the destination pixel value is determined by:

1) color-depth > 256 colors (no palette assumed)
The average pixel value (RGB value) of the source rectangle is used 

2) color-depth <= 256 (palette assumed)
The dominate value of the source rectangle is used.
If the source ports raster op is one of the transparent raster ops,
then the ports background color is never considered dominate, unless
it is the only value present in the source rectangle. */

int ZoomBlit(metaPort *srcPORT ,metaPort *dstPORT, rect *argSrcR, rect *argDstR)
{
/* BobB 5/5/98 - added following two lines to get rid of warning */
	void mwPort2Gbl(rect *inpRect, metaPort *inpPort, rect *dstRect);
	void mwGblClip(metaPort *inpClpPort, rect *outClipR);
	blitRcd blitRec;
	byte colorCnt[256];	/* array of color indexes */
	byte Rshift;	/* R,G, & B shift from word */
	byte Gshift;
	byte Bshift;
	unsigned short ZoomDnVect;	/* Down using color or RGB */
/* BobB 11/3/99 - corrected NColors to unsigned
	short NColors; */			/* total source colors */
	unsigned short NColors;		/* total source colors */
	long tmpColor;				/* pixel color */
	unsigned short maxColor;	/* current max color */
	short maxColorCnt;			/* max color count */
	short redColorCnt;			/* red color count */
	short greenColorCnt;		/* green color count */
	short blueColorCnt;			/* blue color count */
	unsigned short RGBrtn;		/* RGB return value */
	unsigned short Rmask;		/* R,G, & B mask from word */
	unsigned short Gmask;
	unsigned short Bmask;
	long totalPixels;			/* number of pixels in zoom area */
	short srcMode;				/* source pen mode */
	short srcDltX;				/* source width and height */
	short srcDltY;
	short dstDltX;				/* target width and height */
	short dstDltY;
	long srcBack;				/* source back color */
	long dstPen;				/* target pen and back color */
	long dstBack;
	float fSrcDX;				/* src "macro pixel" wdth/ht */
	float fSrcDY;
	float fDstDX;				/* dst "macro pixel" wdth/ht */
	float fDstDY;
	float fSrcXmin;				/* float pnt source macro pixel */
	float fSrcYmin;
	float fSrcXmax;
	float fSrcYmax;
	float fDstXmin;				/* float pnt dest macro pixel */
	float fDstYmin;
	float fDstXmax;
	float fDstYmax;
	short SrcXmin;				/* fixed pnt source macro pixel */
	short SrcYmin;
	short SrcXmax;
	short SrcYmax;
	short DstXmin;				/* fixed pnt dest macro pixel */
	short DstYmin;
	short DstXmax;
	short DstYmax;
	rect dstClipR;				/* global clip rect for target grafMap */
	rect GsrcRect;				/* global rect sizes */
	rect GdstRect;
	rect dstBR;					/* dest rectangle for blitRcd */
	int shfCnt;
#define Zoom_Down_Color 1
#define Zoom_Down_RGB 2
	int i;

	/* ========== Setup source info =============== */

	/* get source rect and convert to global */
	mwPort2Gbl(argSrcR, srcPORT, &GsrcRect);

	srcBack = srcPORT->bkColor;	/* source pen color */
	srcMode = srcPORT->pnMode;	/* source pen mode */
	blitRec.blitSmap = srcPORT->portMap;	/* also place grafMap in blitRcd */

	/* setup vector for Zoom Down to color palette method (default) */
	ZoomDnVect = Zoom_Down_Color;

	/* get total number of colors in source bitmap */
	shfCnt = srcPORT->portMap->pixPlanes;
	if (shfCnt == 1) shfCnt = srcPORT->portMap->pixBits;
	NColors = (1 << (shfCnt)) - 1;	/* total source colors */
	if (NColors > 255)	/* > 256 color (RGB) ? */
	{
	/* hard code values for R,G, & B mask and shift - will get from bitmap later */
		Rmask = 0x7C00;	/* bits 10-14 (msb - not used) */
		Gmask = 0x03E0;	/* bits  5-9 */
		Bmask = 0x001F;	/* bits  0-4 */
		Rshift = 0x0A;
		Gshift = 0x05;
		Bshift = 0x00;
		ZoomDnVect = Zoom_Down_RGB;	/* setup vector for Zoom Down to RGB method */
	}

	/* ========== Setup destination info ========== */

	/* get dest rect and convert to global */
	mwPort2Gbl(argDstR, dstPORT, &GdstRect);

	/* fill out blitRcd based on target grafPort */
	blitRec.blitFlags = bfClipRect;	/* assume rect clip */
	if (dstPORT->portFlags & pfRgnClip)	/* are regions enabled ? */
	{
		blitRec.blitFlags |= bfClipRegn;	/* yes, clip region */
		blitRec.blitRegn = dstPORT->portRegion;
	}

	blitRec.blitRop = dstPORT->pnMode;	/* set raster op */
	blitRec.blitMask = dstPORT->portMask;	/* set plane mask */
	blitRec.blitPat = 1;	/* By nature this is always solid pen */
	blitRec.blitCnt = 1;	/* 1 rect */
	blitRec.blitList = (long) &dstBR;	/* addr of rect */
	blitRec.blitDmap = dstPORT->portMap;	/* set dest grafmap */
	dstBack = dstPORT->bkColor;	/* set colors */
    dstPen = dstPORT->pnColor;        
	blitRec.blitClip = &dstClipR;		/* set pointer to clipR */

	mwGblClip(dstPORT, &dstClipR);	/* convert to global and check port clip */

	/* ======= Setup rectangles and 'macro pixels' =========== */

	/* Get width and height of source and destination rectangle */
	srcDltX = GsrcRect.Xmax - GsrcRect.Xmin;	/* global source width */
	srcDltY = GsrcRect.Ymax - GsrcRect.Ymin;	/* global source height */
	dstDltX = GdstRect.Xmax - GdstRect.Xmin;	/* global destination width */
	dstDltY = GdstRect.Ymax - GdstRect.Ymin;	/* global destination height */

	/* set source and destination "macro pixel" variables for X */
	if (srcDltX > dstDltX)
	{

⌨️ 快捷键说明

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