bitblt的raster operation code在gdi+中的体现是什么?

Magicloud 2005-11-18 09:17:58
也就是如何用gdi+实现反色贴图等功能?
谢谢。
...全文
213 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
swzlxm 2005-12-15
  • 打赏
  • 举报
回复
自己反色
tiaoci 2005-12-13
  • 打赏
  • 举报
回复
我想构造一个ColorMatrix设置到 imageAttr中就可以了

-1, 0, 0,0,1
0,-1, 0,0,1
0, 0,-1,0,1
0, 0, 0,1,0
0, 0, 0,0,1
矩阵大概是这样的吧,或者转置一下,没试过,应该可行
tiaoci 2005-12-13
  • 打赏
  • 举报
回复
有这么麻烦吗?
public void DrawImage (
Image image,
Point[] destPoints,
Rectangle srcRect,
GraphicsUnit srcUnit,
ImageAttributes imageAttr
)

在 imageAttr中指定就可以了吧
Magicloud 2005-12-11
  • 打赏
  • 举报
回复
吐血了,还要unsafe啊……这个gdi+真是糟糕……
gyf19 2005-11-21
  • 打赏
  • 举报
回复
//反色
public static bool Invert(Bitmap b)
{
// GDI+ still lies to us - the return format is BGR, NOT RGB.
BitmapData bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

int stride = bmData.Stride;
System.IntPtr Scan0 = bmData.Scan0;

unsafe
{
byte * p = (byte *)(void *)Scan0;

int nOffset = stride - b.Width*3;
int nWidth = b.Width * 3;

for(int y=0;y<b.Height;++y)
{
for(int x=0; x < nWidth; ++x )
{
p[0] = (byte)(255-p[0]);
++p;
}
p += nOffset;
}
}

b.UnlockBits(bmData);

return true;
}
s5689412 2005-11-20
  • 打赏
  • 举报
回复
好像除了直接使用GDI API之后,GDI+本身并没有这样的功能。
GDI+采用的是对每像素直接进行操作的方式,
在CodeProject上可以以“Image Processing for Dummies with C# and GDI+”为关键字搜索到有关图像处理的系列文章,希望对你有帮助。

17,740

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET Framework
社区管理员
  • .NET Framework社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧