Warning: file_get_contents() [function.file-get-contents]: SSL: 远程主机强迫关闭了一个现有的连接。 in D:\wwwroot\huidong\wwwroot\function.inc.php on line 884

Warning: file_get_contents(https://whois.pconline.com.cn/jsLabel.jsp?ip=127.0.0.1) [function.file-get-contents]: failed to open stream: HTTP request failed! in D:\wwwroot\huidong\wwwroot\function.inc.php on line 884
使用win GDI函数输出透明图像 / 输出图像并裁剪掉图片中的白色 - huidong

huidong

首页 | 会员登录 | 关于争取 2022 寒假做出汇东网 Ver3.0.0 !
搜索文章


void putimage_white(int x, int y, IMAGE* img)
{
	SetWorkingImage(img);

	for (int i = 0; i < img->getwidth(); i++)
	{
		for (int j = 0; j < img->getheight(); j++)
		{
			int color = getpixel(i, j);

			if (color != WHITE)
			{
				SetWorkingImage();
				putpixel(x + i, y + j, color);
				SetWorkingImage(img);
			}
		}
	}
	SetWorkingImage();
}

只是裁剪了白色


上面这个函数效率太低!


推荐用这个函数:

// Windows GDI 透明贴图函数所需 lib
#pragma comment( lib, "MSIMG32.lib")

/**    
 * @brief Windows GDI 函数实现透明贴图    
 * @param x 图像输出位置    
 * @param y 图像输出位置    
 * @param img 要输出的图像    
 * @param bkcolor 图像背景色,即为不输出的颜色    
*/    
inline void putimage_transparent(int x, int y, IMAGE img, COLORREF bkcolor)    
{    
	TransparentBlt(GetImageHDC(GetWorkingImage()), x, y, img.getwidth(), img.getheight(), GetImageHDC(&img), 0, 0, img.getwidth(), img.getheight(), bkcolor);    
}




返回首页


Copyright (C) 2018-2024 huidong