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

📄 yore3.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          */
/*                                                                       */
/*      YORE3.c                                          1.9             */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*      All                                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This file contains the ImageSize function.                       */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*      Giac Dinh, Accelerated Technology, Inc.                          */
/*                                                                       */
/* DATA STRUCTURES                                                       */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* FUNCTIONS                                                             */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* DEPENDENCIES                                                          */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* HISTORY                                                               */
/*                                                                       */
/*         NAME            DATE                    REMARKS               */
/*                                                                       */
/*		   BobB			  5/19/98		Corrected to allow 64K image size*/
/*                                                                       */
/*************************************************************************/

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


/* Function IMAGESIZE computes the number of image bytes required by ReadImage
to store the bitmap area contained within any rectangle similar in size to R.

To avoid shifting the image when reading,
the raster is read starting at the first word that contains any portion
of the image. Each raster is forced to be an even number of bytes long.
This allows STOSW transfers to be memory aligned on the source at least.

If bits/pixel is a multiple of 8, then the size of each line is the
number of bytes required, plus a byte of worst case shift for bytes
per pixel less than 2. This total is rounded up to the next word.

If bits/pixel is not a multiple of 8, then bit shifting may be
required to align source to destination pixels.  The size of each
image line then is;
 
(bits/pixel * pixels per line + worst case bit shift  ) / 8.

The worst case bit shift is 16 bits - (bits/pixel).
This byte count is also rounded up to the next word.  */
long ImageSize( rect *sR )
{
	rect tmpR;
	short bmpixBits, bmpixPlanes;
	short width, height;
	
/* BobB 5/19/98 - added the following line to allow 64K image size */
	long imgSize;

	bmpixBits   = grafPort.portMap->pixBits;
	bmpixPlanes = grafPort.portMap->pixPlanes;
	
	if(globalLevel > 0 )
	{
		U2GR(*sR, &tmpR, 0);
	}
	else
	{
		tmpR = *sR;
	}

/* Calculate height  */
	height = tmpR.Ymax - tmpR.Ymin + 1 ;
/* Calculate pix width  */
	width  = tmpR.Xmax - tmpR.Xmin + 1;

/* Get bit per pixel  */
	if((bmpixBits & 0x07) == 0 )
	{
		width = width * (bmpixBits >> 3);
		if((bmpixBits >> 3) <= 1)
			width += (bmpixBits >> 3);
	}
	else
	{  /* Bits per pixel is not a multiple of 8  */
		width = width * bmpixBits ;
/* Add 7 to round up and extra 16 to avoid shifting on read  */	
		width += 23;
		width -= bmpixBits ;
		width = width >> 3;
	}
/* Round up to even number of bytes  */
	width += width & 1;

/* BobB 5/19/98 - corrected the following line to allow 64K image size
	width = width*height; */
	imgSize = width * height;

/* Multiply times height for total per plane  */	

/* BobB 5/19/98 - corrected the following line to allow 64K image size
	return((width*bmpixPlanes) + sizeof(imageHdr)); */
	return((imgSize * bmpixPlanes) + sizeof(imageHdr));
}


long ImagePara (rect * argPara )
{
	long temp;
	temp = ImageSize(argPara);
	temp += 15;
/* Round up to next paragraph  */
	return(temp >> 4);
}

⌨️ 快捷键说明

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