CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Posts
    11

    Bitmap file reading vs setpixel()

    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.
    Code:
     
    for (x =0; x <256; x++)
    {
       for (y =0; y<256; y++)
       {
           c1.ori_mat[x, y] = (byte)image1.ReadByte();
       }
    }
    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.

    Code:
    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.

  2. #2
    Join Date
    Feb 2005
    Posts
    2,160

    Re: Bitmap file reading vs setpixel()


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured