bitmap.hpp

来自「一款C++小游戏的源代码」· HPP 代码 · 共 71 行

HPP
71
字号
#define BLITCLIP()				\
								\
{	if( sx >= width || sy >= height || ( sx + w ) <= 0 || ( sy + h ) <= 0 )	\
		return;						\
									\
	int dcl, dct, dcb, dcr;			\
									\
	if( sx < 0 ){					\
		x -= sx;					\
		w += sx;					\
		sx = 0;						\
	}								\
	if( sy < 0 ){					\
		y -= sy;					\
		h += sy;					\
		sy = 0;						\
	}								\
	if( sx+w > width ){				\
		w = width - sx;				\
	}								\
	if( sy+h > height ){			\
		h = height - sy;			\
	}								\
									\
	if( dest->clip ){				\
		dcl = dest->cl;				\
		dct = dest->ct;				\
		dcr = dest->cr;				\
		dcb = dest->cb;				\
	}								\
	else{							\
		dcl = dct = 0;				\
		dcb = dest->height;			\
		dcr = dest->width;			\
	}								\
	if( x >= dcr || y >= dcb 		\
		|| ( x + w ) <= dcl || ( y + h ) <= dct )	\
		return;										\
													\
	if( x < dcl ){					\
		sx += dcl - x;				\
		w -= dcl - x;				\
		x = dcl;					\
	}								\
	if( y < dct ){					\
		sy += dct - y;				\
		h -= dct - y;				\
		y = dct;					\
	}								\
	if( x + w > dcr )				\
		w = dcr - x;				\
	if( y + h > dcb )				\
		h = dcb - y; }
										


#define BLITMASK( n )				\
									\
void Bitmap##n::BlitMask( Bitmap* dest, int x, int y, int sx, int sy, int w, int h ) \
{																		\
	BLITCLIP() 															\
																		\
	if( dest == this )													\
		return; /*failed */  											\
	else{																\
		BlitMasked##n( (Bitmap##n*)dest, x, y, sx, sy, w, h );			\
	}																	\
}


⌨️ 快捷键说明

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