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

📄 bmp256.cpp

📁 vc写的源程序,是关于游戏类的程序。调用了系统的很多API
💻 CPP
字号:
#include "graphics.h"
/*
#define PTR_COLORTABLE    1
#define NORMAL_COLORTABLE 2

typedef struct
{
	int   width, height;     // 位图的宽度和高度
	DWORD pitch_byte;        // 以字节计算的位图一行所占的内存空间
	DWORD pitch_word;        // 以字计算的位图所一行占的内存空间
	DWORD pitch_dword;       // 以双字计算的位图一行所占的内存空间
	DWORD surface_byte;      // 以字节计算的位图所占的内存空间
	DWORD surface_word;      // 以字计算的位图所占的内存空间
	DWORD surface_dword;     // 以双字计算的位图所占的内存空间
	int   clipleft, cliptop, // 剪裁矩形的范围
		clipright, clipbottom;
	int   pixelbitcount;     // 每个点所占的位数
	BYTE  colorkey;          // 透明色的索引值
	int   color_table_type;  // 调色板类型
	union
	{
		BYTE  color_table[3][256]; // 调色板
		BYTE  *public_color_table; // 公用调色板
	};
	BYTE  *bit;              // 指向位图数据的指针
}BMP256;

// 建立一个256色位图
BMP256 create_bmp256(int w, int h, int table_type, BYTE *color_table, BYTE c)
{
	BMP256 *bmp = new BMP256;
	if (bmp == NULL)
		return NULL;
	bmp->width =  w;
	bmp->height = h;
	bmp->pitch_byte = w;
	bmp->pitch_word = w / 2;
	bmp->pitch_dword = w / 4;
	bmp->surface_byte = w * h;
	bmp->surface_word = w * h / 2;
	bmp->surface_dword = w * h / 4;
	bmp->clipleft = bmp->cliptop = 0;
	bmp->clipright = w - 1;
	bmp->clipbottom = h - 1;
	bmp->pixelbitcount = 8;
	bmp->colorkey = 0;
	if (table_type == PTR_COLORTABLE)
	{
		bmp->public_color_table = color_table;
		bmp->color_table_type = PTR_COLORTABLE;
	}
	else
	{
		memcpy(bmp->color_table, color_table, 768);
		bmp->color_table_type = NORMAL_COLORTABLE;
	}
	bmp->bit = new char [w * h];
	if (bmp->bit == NULL)
		return NULL;
	return bmp;
}

// 释放一个256色位图
void free_bmp256(BMP256 **bmp)
{
	BMP256 *b = *bmp;
	if (b == NULL)
		return;
	free(b->bit);
	free(b);
	*bmp = NULL;
}

void nomask_bitblt_bmp256(BMP *dest*/

⌨️ 快捷键说明

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