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

📄 util8.c

📁 nucleus 文件系统,内核和彩色图形系统,在小系统上非常好用
💻 C
字号:
/*************************************************************************/
/*                                                                       */
/*         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          */
/*                                                                       */
/*      UTIL8.c                                          1.9             */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*      All                                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This file contains the CreateBitmap & DestroyBitmap functions.   */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*      Robert G. Burrill, Accelerated Technology, Inc.                  */
/*                                                                       */
/* DATA STRUCTURES                                                       */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* FUNCTIONS                                                             */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* DEPENDENCIES                                                          */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* HISTORY                                                               */
/*                                                                       */
/*         NAME            DATE                    REMARKS               */
/*                                                                       */
/*                                                                       */
/*************************************************************************/

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

/* Local functions  */
void *GrafAlloc(int memSize);
void GrafFree(void *freePtr);
int InitBitmap(int argDEVICE, grafMap *argGRAFMAP);
void CloseBitmap(grafMap *argCGMAP);
void InitPort(metaPort *argPORT);
void PortBitmap(grafMap *ptrBMAP);
void PortSize(int psWDX,  int psHTY);
void ClipRect(rect *cRECT);


/* Function CreateBitmap creates an off-screen port and bitmap of a specified
width and height that matches the format of the currently active (normally
screen) bitmap.  aMEMTYPE specifies where the bitmap is to located in
conventional memory (cMEMORY).

CreateBitmap returns with a pointer to the new port to access the bitmap,
or a NULL pointer if the port and bitmap creation fails (eg. insufficient
memory for the bitmap size specified). */
metaPort *CreateBitmap(int aMEMTYPE, int aWIDTH, int aHEIGHT)
{
	grafMap *offBitmap;	/* offscreen grafMap record */
	metaPort *offScreen;	/* offscreen grafPort record */

	/* only memory based bitmaps are support at this time */
	if(aMEMTYPE != cMEMORY) return(NULL);

	/* allocate offscreen grafMap data record */
	offBitmap = (grafMap *) GrafAlloc(sizeof(grafMap));
	if (offBitmap == NULL) return(NULL);

	/* allocate offscreen grafPort data record */
	offScreen = (metaPort *) GrafAlloc(sizeof(metaPort));
	if (offScreen == NULL)
	{
		GrafFree((void *) offBitmap);
		return(NULL);
	}

	/* Set the dimension of the offscreen bitmap to the aWIDTH & aHEIGHT */
	offBitmap->pixWidth = aWIDTH;
	offBitmap->pixHeight = aHEIGHT;

	#if(PROT286 == yes)
	offBitmap->pixHeight++;	/* allow for caching ahead rowtable pointers */
	#endif

	/* Set the device color type equal to the screen bitmap's */
	offBitmap->pixBits = grafPort.portMap->pixBits;
	offBitmap->pixPlanes = grafPort.portMap->pixPlanes;
	offBitmap->pixResX = grafPort.portMap->pixResX;
	offBitmap->pixResY = grafPort.portMap->pixResY;

	/* Init the new memory bitmap */
	if (InitBitmap(aMEMTYPE, offBitmap) != 0)
	{
		CloseBitmap(offBitmap);
		GrafFree((void *) offScreen);
		GrafFree((void *) offBitmap);
		return(NULL);
	}

	/* initialize the offscreen port */
	InitPort(offScreen);
	PortBitmap(offBitmap);
	PortSize(aWIDTH, aHEIGHT);
	ClipRect(&offScreen->portRect);

	/* the offscreen port and bitmap are now ready */
	return (offScreen);
}


/* Function DestroyBitmap frees a port and bitmap previously created with
CreateBitmap. */
void DestroyBitmap(metaPort *offPort)
{
	grafMap *offBmap;	/* offscreen grafMap record */

	offBmap = offPort->portMap;	/* save pointer to the bitmap */
	CloseBitmap(offBmap);
	GrafFree((void *) offPort);
	GrafFree((void *) offBmap);
	return;
}

⌨️ 快捷键说明

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