位图文件读取与setpixel() [英] Bitmap file reading vs setpixel()

查看:103
本文介绍了位图文件读取与setpixel()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我对位图文件有问题.要读取位图(256x256)文件,我通过划痕标题使用了二维数组.

Hi all,

I have got a problem regarding Bitmap file. To read the bitmap (256x256) file I use two dimensional array by scrip the header.

for (x =0; x <256; x++)
{
   for (y =0; y<256; y++)
   {
       c1.ori_mat[x, y] = (byte)image1.ReadByte();
   }
}



现在,在ori_mat数组上执行某项操作(不是反向操作或其他操作,仅是具有值的操作)之后,我想使用setpixel()函数在图片框上显示图像.



Now after doing something on the ori_mat array (not reverse or other thing, just something with value), I want to show the image on a picture box using setpixel() function.

Bitmap img = new Bitmap(256, 256);
for (int i = 0; i < 256; i++)
     for (int j =0; j<256; j++)
     {
        img.SetPixel(i,j, Color.FromArgb(c1.ori_mat[i, j], c1.ori_mat[i, j],c1.ori_mat[i,j]));
      }
      pictureBox1.Image= img;



但是图片框中显示的图像是反向或镜像的(与原始图片不同).

有人可以请问我的问题是什么.提前谢谢.



But the image is shown in the picture box is reverse or mirrored (not the same as original picture).

Can someone please whats my problem. Thanks in advance.
Take care and bye.

推荐答案

Bitmap类具有 RotateFlip 方法,该方法可能对您有用(有关详细信息,请参见帮助"系统) ),尽管我不得不说您的整个方法似乎有点复杂.

当然,这可能是一个完全正确的理由,但是如果您要解释自己要做什么,那么有人也许可以提出一种更有效的方法来实现您的目标.

祝你好运. :)
The Bitmap class has a RotateFlip method which may be of use to you (see the Help system for details) although I have to say that your whole methodology seems a little complicated.

There may of course be a perfectly valid reason for this but if you were to explain what it is that you are trying to do, someone might be able to suggest a more efficient way of achieving your aims.

Good luck. :)


这篇关于位图文件读取与setpixel()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆