2011-10-07 46 views
2

已更新: 一直在四处寻找,并试图找出什么替代方案为Windows Phone 7.1的BitmapData。我已经评论了有问题的代码。我知道Lockbits和它的快速比较,以获得设置像素等。根据我的理解,BitmapData将图像锁定到内存以准备操作。 BmpData.Scan0充当指向内存的指针。BitmapData和Marshal.Copy? windows phone有什么其他选择?

如果我没有这样做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; 
    } 

任何帮助表示赞赏。 谢谢

+0

目前还不清楚你想要做什么:克隆图像,操纵图像?都? –

+0

是的,我想克隆,然后处理图像。我已经介绍了一些更多的代码,如果它澄清一点。 – user970355

回答

2

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

+0

你能解释一下更多的细节,以了解在上述场景中这可能有用吗?我看过[leadtools](http://www.leadtools.com/Help/Leadtools/v175/DH/co/leadtools.codecs~leadtools.codecs.rastercodecs.html)和其他一些。任何与BitmapData或Bitlocks类似的东西? – user970355