没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
转自:http://www.cnblogs.com/ruimingde/archive/2012/01/12/2321005.html
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
using System.Drawing.Drawing2D;
namespace Ly.ImageLibrary
{
public class PngImage
{
[DllImport("gdi32.dll")]
public static extern IntPtr ExtCreateRegion(IntPtr lpXform, uint nCount,
ref byte lpRgnData);
public static int RGN_AND = 1;
public static int RGN_OR = 2;
public static int RGN_XOR = 3;
public static int RGN_DIFF = 4;
public static int RGN_COPY = 5;
public static int RGN_MIN = RGN_AND;
public static int RGN_MAX = RGN_COPY;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
using System.Drawing.Drawing2D;
namespace Ly.ImageLibrary
{
public class PngImage
{
[DllImport("gdi32.dll")]
public static extern IntPtr ExtCreateRegion(IntPtr lpXform, uint nCount,
ref byte lpRgnData);
public static int RGN_AND = 1;
public static int RGN_OR = 2;
public static int RGN_XOR = 3;
public static int RGN_DIFF = 4;
public static int RGN_COPY = 5;
public static int RGN_MIN = RGN_AND;
public static int RGN_MAX = RGN_COPY;
[DllImport("gdi32.dll")]
public static extern int CombineRgn(IntPtr hrgnDest, IntPtr hrgnSrc1, IntPtr hrgnSrc2,
int fnCombineMode);
[DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr hObject);
public static Region ImageToRegion(Image AImage, Color ATransparent)
{
//转贴请注明出处ZswangY37(wjhu111#21cn.com) 时间2007-05-25
if (AImage == null) return null;
Bitmap vBitmap = new Bitmap(AImage);
BitmapData vBitmapData = vBitmap.LockBits(new Rectangle(0, 0, vBitmap.Width, vBitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppRgb);
int vAddress = (int)vBitmapData.Scan0;
int vOffset = vBitmapData.Stride - vBitmap.Width * 4; // 每行多出的字节数
int h = vBitmap.Height, w = vBitmap.Width;
int vTransparent = ColorTranslator.ToWin32(ATransparent); // 透明色
int vAllocRect = (0x1000 - sizeof(uint) * 8) / sizeof(int); // 预分配的矩形数
if (h * w < vAllocRect) vAllocRect = h * w;
Byte[] vBuffer = new byte[sizeof(uint) * 8 + sizeof(int) * 4 * vAllocRect];
//头信息dwSize\iType\nCount\nRegSize
uint vCount = 0;
vBuffer[0] = sizeof(uint) * 8; //dwSize//头信息大小
vBuffer[4] = 1; //iType//int RDH_RECTANGLES = 1;//数据类型
IntPtr vResult = IntPtr.Zero;
uint vPointer = sizeof(uint) * 8;
bool vWriteRect = false;
剩余6页未读,继续阅读
资源评论
江湖人儿
- 粉丝: 6
- 资源: 32
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功