www.pudn.com > cwin.rar > GETPIXEL.C
/*-----------------------------------------------------------
函数 _GetPixel : 取指定坐标处的象素颜色
-----------------------------------------------------------*/
#include
int _Cdecl _GetPixel(x,y)
int x,y; /* 象素坐标 */
{
/*-- 将象素坐标换算为显示存储器VRAM中的地址 -----------*/
char far *addr = MK_FP(0xa000,(y+_ScreenTop)*_ScreenWidth+(x>>3));
/*-- 计算象素在字节内的位置 ---------------------------*/
unsigned char mask = 0x80 >> (x&7);
int color = 0,i;
for(i=0;i<4;i++)
{
/*-- 选择颜色平面i ----------------*/
outportb(0x3ce,4);
outportb(0x3cf,i);
if((*addr)&mask)
color |= (0x01<