简体   繁体   English

图像从双数组逐像素绘制

[英]Image draw pixel by pixel from double array

I am trying to achieve something but after hours of search, I decided just to ask the more experienced. 我正在尝试取得一些成就,但是经过数小时的搜索,我决定只问一些经验丰富的人。 I am reading a pgm file(grayscale image represented with the value of gray for every pixel) and loading it into double array => data[,]. 我正在读取一个pgm文件(每个像素用灰度值表示的灰度图像),并将其加载到double array => data [,]中。 I am trying to make a double loop that will fill an image object in WPF window with the correct grayscale value for every pixel. 我正在尝试制作一个双循环,该循环将用每个像素的正确灰度值填充WPF窗口中的图像对象。

Here is my need more code-like represented: 这是我需要更多类似代码的表示形式:

int[,] data = new int[img.width,img.height];` 
for(int i=0; i<img.Height;i++)`
{
    for(int j=0; j<img.Width;j++)
    {
        //line that will fill image with pixel[i,j];
    }

} 

You probably are looking for Bitmap.SetPixel method. 您可能正在寻找Bitmap.SetPixel方法。 However, this may prove to be quite slow processing. 但是,这可能证明是非常缓慢的处理。 You can speed up performance by using Bitmap.LockBits method. 您可以通过使用Bitmap.LockBits方法来提高性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM