C# Windows Mobile 利用Com 透明图片绘制
来源:互联网 发布:知乎 巴黎观光巴士 编辑:程序博客网 时间:2024/04/27 22:04
//扩展Graphics
public static class GraphicsExtend
{
public enum PixelFormatID : int
{
PixelFormatIndexed = 0x00010000, // Indexes into a palette
PixelFormatGDI = 0x00020000, // Is a GDI-supported format
PixelFormatAlpha = 0x00040000, // Has an alpha component
PixelFormatPAlpha = 0x00080000, // Pre-multiplied alpha
PixelFormatExtended = 0x00100000, // Extended color 16 bits/channel
PixelFormatCanonical = 0x00200000,
PixelFormatUndefined = 0,
PixelFormatDontCare = 0,
PixelFormat1bppIndexed = (1 | (1 << 8) | PixelFormatIndexed | PixelFormatGDI),
PixelFormat4bppIndexed = (2 | (4 << 8) | PixelFormatIndexed | PixelFormatGDI),
PixelFormat8bppIndexed = (3 | (8 << 8) | PixelFormatIndexed | PixelFormatGDI),
PixelFormat16bppRGB555 = (5 | (16 << 8) | PixelFormatGDI),
PixelFormat16bppRGB565 = (6 | (16 << 8) | PixelFormatGDI),
PixelFormat16bppARGB1555 = (7 | (16 << 8) | PixelFormatAlpha | PixelFormatGDI),
PixelFormat24bppRGB = (8 | (24 << 8) | PixelFormatGDI),
PixelFormat32bppRGB = (9 | (32 << 8) | PixelFormatGDI),
PixelFormat32bppARGB = (10 | (32 << 8) | PixelFormatAlpha | PixelFormatGDI | PixelFormatCanonical),
PixelFormat32bppPARGB = (11 | (32 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatGDI),
PixelFormat48bppRGB = (12 | (48 << 8) | PixelFormatExtended),
PixelFormat64bppARGB = (13 | (64 << 8) | PixelFormatAlpha | PixelFormatCanonical | PixelFormatExtended),
PixelFormat64bppPARGB = (14 | (64 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatExtended),
PixelFormatMax = 15
}
// Pulled from imaging.h in the Windows Mobile 5.0 Pocket PC SDK
public enum BufferDisposalFlag : int
{
BufferDisposalFlagNone,
BufferDisposalFlagGlobalFree,
BufferDisposalFlagCoTaskMemFree,
BufferDisposalFlagUnmapView
}
// Pulled from imaging.h in the Windows Mobile 5.0 Pocket PC SDK
public enum InterpolationHint : int
{
InterpolationHintDefault,
InterpolationHintNearestNeighbor,
InterpolationHintBilinear,
InterpolationHintAveraging,
InterpolationHintBicubic
}
// Pulled from imaging.h in the Windows Mobile 5.0 Pocket PC SDK
public struct ImageInfo
{
// I am being lazy here, I don't care at this point about the RawDataFormat GUID
public uint GuidPart1;
public uint GuidPart2;
public uint GuidPart3;
public uint GuidPart4;
public PixelFormatID pixelFormat;
public uint Width;
public uint Height;
public uint TileWidth;
public uint TileHeight;
public double Xdpi;
public double Ydpi;
public uint Flags;
}
// Pulled from imaging.h in the Windows Mobile 5.0 Pocket PC SDK
[ComImport, Guid("327ABDA7-072B-11D3-9D7B-0000F81EF32E"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComVisible(true)]
public interface IImagingFactory
{
uint CreateImageFromStream(); // This is a place holder
uint CreateImageFromFile(string filename, out IImage image);
// We need the MarshalAs attribute here to keep COM interop from sending the buffer down as a Safe Array.
uint CreateImageFromBuffer([MarshalAs(UnmanagedType.LPArray)] byte[] buffer, uint size, BufferDisposalFlag disposalFlag, out IImage image);
uint CreateNewBitmap(); // This is a place holder
uint CreateBitmapFromImage(); // This is a place holder
uint CreateBitmapFromBuffer(); // This is a place holder
uint CreateImageDecoder(); // This is a place holder
uint CreateImageEncoderToStream(); // This is a place holder
uint CreateImageEncoderToFile(); // This is a place holder
uint GetInstalledDecoders(); // This is a place holder
uint GetInstalledEncoders(); // This is a place holder
uint InstallImageCodec(); // This is a place holder
uint UninstallImageCodec(); // This is a place holder
}
// Pulled from imaging.h in the Windows Mobile 5.0 Pocket PC SDK
[ComImport, Guid("327ABDA9-072B-11D3-9D7B-0000F81EF32E"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComVisible(true)]
public interface IImage
{
uint GetPhysicalDimension(out Size size);
uint GetImageInfo(out ImageInfo info);
uint SetImageFlags(uint flags);
// "Correct" declaration: uint Draw(IntPtr hdc, ref Rectangle dstRect, ref Rectangle srcRect);
uint Draw(IntPtr hdc, ref Rectangle dstRect, IntPtr NULL);
uint PushIntoSink(); // This is a place holder
uint GetThumbnail(uint thumbWidth, uint thumbHeight, out IImage thumbImage);
}
}
运用:
GraphicsExtend.IImage img;
GraphicsExtend.IImagingFactory factory=(GraphicsExtend.IImagingFactory)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("327ABDA8-072B-11D3-9D7B-0000F81EF32E")));
private void MainPanel_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawImage(map, rtlDes, rtlSrc, GraphicsUnit.Pixel);
factory.CreateImageFromFile(DALUtility.AppPath + @"/Pic/" + "Test.png", out img);
IntPtr dstHDC = e.Graphics.GetHdc();
注:此矩形区域非 Winform 区域 而是:X,Y,top,left
Rectangle rect = new Rectangle(47, 150,150+47,25+150);
img.Draw(dstHDC, ref rect, IntPtr.Zero);
e.Graphics.ReleaseHdc(dstHDC);
}
- C# Windows Mobile 利用Com 透明图片绘制
- C#透明图片绘制和圆柱绘制
- Windows Mobile 透明控件
- Windows Mobile下画透明PNG图片的解决方案
- Windows Mobile下画透明PNG图片的解决方案
- Windows Mobile下画透明PNG图片的解决方案
- Windows Mobile C#实现GIF图片播放
- C#绘制透明区域
- mobile图片的透明处理
- Windows Mobile 透明控件2
- Windows Mobile实现透明控件
- Windows Mobile实现透明控件
- net cf绘制透明图片
- Windows Mobile下画透明PNG图片的解决方案----把PNG转成BMP再画
- C#生成透明图片
- C#中图片透明
- C# windows mobile中实现控件的动态绘制与动态删除
- c# 窗口图片绘制
- 关于xml 和 html 的转义字符
- 利用php中的eval来模拟java中的动态代理
- 备份操作 图解地址!
- 從 ifconfig 中得到 IP地址
- c连接符
- C# Windows Mobile 利用Com 透明图片绘制
- C语言宏定义##连接符和#符的使用
- Linux技巧:Linux系统下批量替换文件内容
- GEF 学习系列之六:图元的选择框和反馈显示
- 迟到千年
- 删除3天前的文件
- QA List
- 人生若只如初见
- SQL农历转换函数