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

📄 imagelist.cpp

📁 diablo图形引擎例子
💻 CPP
📖 第 1 页 / 共 3 页
字号:
		}
	}

}

void ImageList::DrawAlpha125(int index, int x, int y, WORD *lpBitmap, long lPitch)
{
	WORD mask1=m_dwAlphaMask_SHR1;
	WORD mask2=m_dwAlphaMask_SHR2;
	WORD mask3=m_dwAlphaMask_SHR3;
	int  ofs=m_lpOffsetTable[index]/2;
	WORD *s = m_lpDataBuffer+ofs;

	WORD Width  = *s++;
	WORD Height = *s++;
	// 如果图像不在可见范围内,就不画了
	if( (x + Width ) < 0 || x >= DisplayMode_Width || (y + Height) < 0 || y >= DisplayMode_Height) return;
	// 如果图像完全在可见范围内,就直接调用PutImage
	if( x >= 0 && (x + Width) < DisplayMode_Width && y >= 0 && (y + Height) < DisplayMode_Height )
	{
		WORD *d = lpBitmap + y * lPitch + x;
		while( 1 )
		{ 
			WORD c = *s++, count = c & BitDataMask;
			if( c == BitEndOfImageMask )	// 图像结束
			break;			
			else
			if( c & BitWhiteLineMask )		// 空白行
			{ 
				d += lPitch * count;
			} 
			else
			if(c & BitPixelMask)		// 像素点
			{ 
				for( int i=0; i<count; i++ ) 
				{ 
					_asm
						{
							mov edi,d
							mov esi,s
							mov ax,[edi]
							shr ax,1
							and ax,mask1
							mov dx,ax
							shr ax,1
							and ax,mask2
							add dx,ax
							shr ax,1
							and ax,mask3
							add ax,dx
							mov dx,[esi]
							shr dx,3
							and dx,mask3
							add ax,dx
							mov [edi],ax
						}
						d++;s++;
					//*d++ = *s++;						
				} 
			} 
			else 
			if(c & BitTransparentMask) // 透明点
			{ 
			 	d += count;
			} 
			else
			if( c == BitEndOfLineMask )		// 行结束
				{
					d+=(lPitch-Width);				
			}  
		}  
		return;
	}
	// 图像只有部分可见,要考虑各个边界相交的情况
	int ix=x, iy=y;	// 当前处理的行列坐标
	// 屏幕范围以上不可见部分
	while( iy < 0 )
	{
		WORD c = *s++, count = c & BitDataMask;
		if( c == BitEndOfImageMask ) return;			// 图像结束
		if( c & BitWhiteLineMask )			// 忽略空白行(通常在图像顶部和底部)
		{
			iy +=count;
		}
		else if( c & BitPixelMask )		// 跳过图像数据
		{
			s +=count;
		}
		else						// 忽略透明部分
		{
		}
		if( c & BitEndOfLineMask )		// 一行结束,换行
		{
			iy++;	
		}
	}
	// 屏幕可见范围以内
	WORD *d = (WORD *)lpBitmap + iy * lPitch;
	if( ix > 0 && ix < DisplayMode_Width) d+=ix;
	while(iy<DisplayMode_Height)
	{
		WORD c = *s++, count = c & BitDataMask;
		if( c == BitEndOfImageMask ) return;		// 图像结束
		if( c & BitWhiteLineMask )		// 忽略空白行(通常在图像顶部和底部)
		{
			iy +=count;
			d += lPitch * count;
		}
		else						// 非空白行,要考虑如何画
		{
			if( ix < 0  )
			{
				if( ix + count < 0 )	// 1 不画 .... /
				{
					if( c & BitPixelMask ) s +=count;	// 忽略像素
					ix += count;
				}
				else					// 2 部分画 ../..
				{
					if( c & BitPixelMask )
					{
						s += -ix;		// 忽略不可见部分
						ix += count;
						for( int i=0; i<ix; i++ ) 
						{
							_asm
							{ 
								mov edi,d
								mov esi,s
								mov ax,[edi]
								shr ax,1
								and ax,mask1
								mov dx,ax
								shr ax,1	
								and ax,mask2
								add dx,ax
								shr ax,1
								and ax,mask3
								add ax,dx
								mov dx,[esi]
								shr dx,3
								and dx,mask3
								add ax,dx
								mov [edi],ax	
							}
							d++;s++;
							//*d++ = *s++;
						}
					}
					else				// 透明部分
					{
						ix += count;
						d += ix;	
					}
				}
			}
			else if( ix >= DisplayMode_Width )			// 5 不画	\ ....
			{
				if( c & BitPixelMask ) s +=count;		// 忽略像素
				// ix += count;						// 没有必要,反正已经出界了
			}
			else // ( ix > 0 && ix <= GraphWidth )
			{
				if( ix + count >= DisplayMode_Width)	// 4 部分画  ..\..`
				{
					if( c & BitPixelMask )
					{
						for( int i=ix; i<DisplayMode_Width; i++ ) 
						{
							_asm
							{ 
								mov edi,d
								mov esi,s
								mov ax,[edi]
								shr ax,1
								and ax,mask1
								mov dx,ax
								shr ax,1
								and ax,mask2
								add dx,ax
								shr ax,1
								and ax,mask3
								add ax,dx
								mov dx,[esi]
								shr dx,3
								and dx,mask3
								add ax,dx
								mov [edi],ax							
							}
								d++;s++;
							//*d++ = *s++;
						}
						ix += count;
						s += (ix - DisplayMode_Width);		// 跳过超出部分
					}
					else
					{
						ix += count;
					}
				}
				else							// 3 全画	 /....\`
				{
					if( c & BitPixelMask )				// 显示图像
					{
						for( int i=0; i<count; i++ ) 
						{
							_asm
							{ 
								mov edi,d
								mov esi,s
								mov ax,[edi]
								shr ax,1
								and ax,mask1
								mov dx,ax
								shr ax,1	
								and ax,mask2
								add dx,ax
								shr ax,1
								and ax,mask3
								add ax,dx
								mov dx,[esi]
								shr dx,3
								and dx,mask3
								add ax,dx
								mov [edi],ax	
							}
							d++;s++;
							
						//	*d++ = *s++;
						}
					}
					else							// 跳过透明部分
					{
						d += count;
					}
					ix += count;
				}
			}
		}
		if( c & BitEndOfLineMask )		// 一行结束,换行
		{
			ix = x;
			iy++;
	
			d = (WORD *)lpBitmap + iy * lPitch;
			if( ix > 0 && ix < DisplayMode_Width ) d += ix;
		}
	}
}

void ImageList::DrawAlpha500(int index, int x, int y, WORD *lpBitmap, long lPitch)
{
	WORD mask1=m_dwAlphaMask_SHR1;
	int  ofs=m_lpOffsetTable[index]/2;
	WORD *s = m_lpDataBuffer+ofs;

	WORD Width  = *s++;
	WORD Height = *s++;
	// 如果图像不在可见范围内,就不画了
	if( (x + Width ) < 0 || x >= DisplayMode_Width || (y + Height) < 0 || y >= DisplayMode_Height) return;
	// 如果图像完全在可见范围内,就直接调用PutImage
	if( x >= 0 && (x + Width) < DisplayMode_Width && y >= 0 && (y + Height) < DisplayMode_Height )
	{
		WORD *d = lpBitmap + y * lPitch + x;
		while( 1 )
		{ 
			WORD c = *s++, count = c & BitDataMask;
			if( c == BitEndOfImageMask )	// 图像结束
			break;			
			else
			if( c & BitWhiteLineMask )		// 空白行
			{ 
				d += lPitch * count;
			} 
			else
			if(c & BitPixelMask)		// 像素点
			{ 
				for( int i=0; i<count; i++ ) 
				{ 
					_asm
						{
							mov edi,d
							mov esi,s
							mov ax,[edi]
							shr ax,1
							mov dx,[esi]
							shr dx,1
							and ax,mask1
							and dx,mask1
							add ax,dx
							mov [edi],ax
						}
						d++;s++;
					//*d++ = *s++;						
				} 
			} 
			else 
			if(c & BitTransparentMask) // 透明点
			{ 
			 	d += count;
			} 
			else
			if( c == BitEndOfLineMask )		// 行结束
				{
					d+=(lPitch-Width);				
			}  
		}  
		return;
	}
	// 图像只有部分可见,要考虑各个边界相交的情况
	int ix=x, iy=y;	// 当前处理的行列坐标
	// 屏幕范围以上不可见部分
	while( iy < 0 )
	{
		WORD c = *s++, count = c & BitDataMask;
		if( c == BitEndOfImageMask ) return;			// 图像结束
		if( c & BitWhiteLineMask )			// 忽略空白行(通常在图像顶部和底部)
		{
			iy +=count;
		}
		else if( c & BitPixelMask )		// 跳过图像数据
		{
			s +=count;
		}
		else						// 忽略透明部分
		{
		}
		if( c & BitEndOfLineMask )		// 一行结束,换行
		{
			iy++;	
		}
	}
	// 屏幕可见范围以内
	WORD *d = (WORD *)lpBitmap + iy * lPitch;
	if( ix > 0 && ix < DisplayMode_Width) d+=ix;
	while(iy<DisplayMode_Height)
	{
		WORD c = *s++, count = c & BitDataMask;
		if( c == BitEndOfImageMask ) return;		// 图像结束
		if( c & BitWhiteLineMask )		// 忽略空白行(通常在图像顶部和底部)
		{
			iy +=count;
			d += lPitch * count;
		}
		else						// 非空白行,要考虑如何画
		{
			if( ix < 0  )
			{
				if( ix + count < 0 )	// 1 不画 .... /
				{
					if( c & BitPixelMask ) s +=count;	// 忽略像素
					ix += count;
				}
				else					// 2 部分画 ../..
				{
					if( c & BitPixelMask )
					{
						s += -ix;		// 忽略不可见部分
						ix += count;
						for( int i=0; i<ix; i++ ) 
						{
							_asm
							{ 
							mov edi,d
							mov esi,s
							mov ax,[edi]
							shr ax,1
							mov dx,[esi]
							shr dx,1
							and ax,mask1
							and dx,mask1
							add ax,dx
							mov [edi],ax	
							}
							d++;s++;
							//*d++ = *s++;
						}
					}
					else				// 透明部分
					{
						ix += count;
						d += ix;	
					}
				}
			}
			else if( ix >= DisplayMode_Width )			// 5 不画	\ ....
			{
				if( c & BitPixelMask ) s +=count;		// 忽略像素
				// ix += count;						// 没有必要,反正已经出界了
			}
			else // ( ix > 0 && ix <= GraphWidth )
			{
				if( ix + count >= DisplayMode_Width)	// 4 部分画  ..\..`
				{
					if( c & BitPixelMask )
					{
						for( int i=ix; i<DisplayMode_Width; i++ ) 
						{
							_asm
							{ 
							mov edi,d
							mov esi,s
							mov ax,[edi]
							shr ax,1
							mov dx,[esi]
							shr dx,1
							and ax,mask1
							and dx,mask1
							add ax,dx
							mov [edi],ax							
							}
								d++;s++;
							//*d++ = *s++;
						}
						ix += count;
						s += (ix - DisplayMode_Width);		// 跳过超出部分
					}
					else
					{
						ix += count;
					}
				}
				else							// 3 全画	 /....\`
				{
					if( c & BitPixelMask )				// 显示图像
					{
						for( int i=0; i<count; i++ ) 
						{
							_asm
							{ 
							mov edi,d
							mov esi,s
							mov ax,[edi]
							shr ax,1
							mov dx,[esi]
							shr dx,1
							and ax,mask1
							and dx,mask1
							add ax,dx
							mov [edi],ax	
							}
							d++;s++;
							
						//	*d++ = *s++;
						}
					}
					else							// 跳过透明部分
					{
						d += count;
					}
					ix += count;
				}
			}
		}
		if( c & BitEndOfLineMask )		// 一行结束,换行
		{
			ix = x;
			iy++;
	
			d = (WORD *)lpBitmap + iy * lPitch;
			if( ix > 0 && ix < DisplayMode_Width ) d += ix;
		}
	}


}

void ImageList::DrawAlpha750(int index, int x, int y, WORD *lpBitmap, long lPitch)
{
	
	WORD mask1=m_dwAlphaMask_SHR1;
	WORD mask2=m_dwAlphaMask_SHR2;
	int  ofs=m_lpOffsetTable[index]/2;
	WORD *s = m_lpDataBuffer+ofs;

	WORD Width  = *s++;
	WORD Height = *s++;
	// 如果图像不在可见范围内,就不画了
	if( (x + Width ) < 0 || x >= DisplayMode_Width || (y + Height) < 0 || y >= DisplayMode_Height) return;
	// 如果图像完全在可见范围内,就直接调用PutImage
	if( x >= 0 && (x + Width) < DisplayMode_Width && y >= 0 && (y + Height) < DisplayMode_Height )
	{
		WORD *d = lpBitmap + y * lPitch + x;
		while( 1 )
		{ 
			WORD c = *s++, count = c & BitDataMask;
			if( c == BitEndOfImageMask )	// 图像结束
			break;			
			else
			if( c & BitWhiteLineMask )		// 空白行
			{ 
				d += lPitch * count;
			} 
			else
			if(c & BitPixelMask)		// 像素点
			{ 
				for( int i=0; i<count; i++ ) 
				{ 
					_asm
						{
							mov edi,d
							mov esi,s
							mov ax,[edi]
							shr ax,2
							and ax,mask2
							mov dx,[esi]
							mov bx,dx
							shr bx,1
							and bx,mask1
							shr dx,2
							and dx,mask2
							add dx,bx
							add ax,dx

⌨️ 快捷键说明

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