【发布时间】:2011-10-07 15:17:01
【问题描述】:
更新: 一直在环顾四周,试图找出 Windows phone 7.1 的 BitmapData 有什么替代方案。我已经注释掉了有问题的代码。我知道 Lockbits,并且与获取设置像素等相比,它的速度更快。 根据我的理解,BitmapData 将图像锁定到内存以供操作。 BmpData.Scan0 充当指向内存的指针。
如果我要在没有 BitmapData 的情况下执行此操作,请说 Get.Pixel 并将其映射到内存。并使用 Set.Pixel 操作一些图像数据?
P.S:关于处理速度;我不想改变很多像素。
public int Edit(Bitmap BmpIn, byte[] BIn, byte BitsPerByte)
{
int LengthBytes = 1 + 31 / BitsPerByte;
int TextLength = 1 + (8 * BIn.Length - 1) / BitsPerByte;
//BitmapData BmpData = BmpIn.LockBits(new Rectangle(0, 0, BmpIn.Width, BmpIn.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
RGB = new byte[2 + LengthBytes + TextLength];
//Marshal.Copy(BmpData.Scan0, RGB, 0, RGB.Length);
InsertBitsPerByte(BitsPerByte);
SetMasks(BitsPerByte);
InsertLength(LengthBytes, TextLength, BitsPerByte);
InsertBytes(BIn, BitsPerByte);
//Marshal.Copy(RGB, 0, BmpData.Scan0, RGB.Length);
BmpIn.UnlockBits(BmpData);
return TextLength;
}
任何帮助表示赞赏。 谢谢
【问题讨论】:
-
不清楚您要做什么:克隆图像,操作图像?两者都有?
-
是的,我正在尝试克隆然后操作图像。如果更清楚一点,我已经介绍了更多代码。
标签: c# windows-phone-7 windows-phone-7.1 getpixel lockbits