BitmapData 和 Marshal.Copy? Windows Phone 有什么替代品?

发布于 2024-12-08 23:32:21 字数 1042 浏览 4 评论 0原文

更新: 一直在环顾四周,试图找出 Windows Phone 7.1 对于 BitmapData 有什么替代方案。我已经注释掉了有问题的代码。我知道 Lockbits,并且与获取设置像素等相比,它的速度更快。 根据我的理解,BitmapData 将图像锁定到内存中以供操作。 BmpData.Scan0 充当指向内存的指针。

如果我要在没有 BitmapData 的情况下执行此操作,请说 Get.Pixel 并将其映射到内存。并使用 Set.Pixel 操作一些图像数据?

PS:关于处理速度;我不想改变很多像素。

  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;
   }

任何帮助表示赞赏。 谢谢

UPDATED:
Been looking around and trying to figure out what alternative there is for windows phone 7.1 for BitmapData. I have Commented out the code in question. I am aware of Lockbits and that its fast in comparison to get set pixels and so on.
As per my understanding, BitmapData Locks the image to memory ready for manipulation.
BmpData.Scan0 acts as a pointer to the memory.

If I were to do this without BitmapData, say Get.Pixel and map it to memory. and manipulate some of image data with Set.Pixel?

P.S: In regards to processing speed; I am not looking to change alot of pixels.

  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;
   }

Any help appreciated.
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

与往事干杯 2024-12-15 23:32:21

看看 WriteableBitmapEx。这将允许您在图像中进行像素操作。

Have a look at WriteableBitmapEx. This will allow you to do pixel manipulation within an image.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文