[問題] C# bitmap與陣列問題

作者: MarkHero (Mark)   2013-05-20 18:51:53
是這樣的,小弟正在研究資訊隱藏的部分,
語法是C#,撰寫平台是Visual studio 2012 ,
我的問題是:
我在全域變數中宣告了一個二維陣列G1,
並且宣告了一個bitmap變數,
int [,] G1 = new int[512, 512];
Bitmap fileimage,bm1;
然後讀取了一張bmp圖片,並提取他的像素,
bm1 = (Bitmap)pictureBox1.Image;
請教我該如何將bm1中的像素值放置G1當中!?
也就是G1 = bm1!?
我有先寫了一個for迴圈如下:
int w1 = pictureBox1.Image.Width;
int h1 = pictureBox1.Image.Height;
int x;
int y;
for (y = 0; y <= h1 - 1; y++)
{
for (x = 0; x <= w1 - 1; x++)
{
}
}
問題1: 我該如何將bm1中的262,144個像素值轉入512*512的陣列G1中!?
問題2: 上述這段程式必須寫在for迴圈當中,讓他一個一個丟進去,
還是寫在for迴圈之外,讓他一口氣全部丟進去呢!?
(問題2我覺得應該兩種方法都可以,可是如果我先在for當中針對bm1進行運算,
運算完畢再丟進去G1,會否比較好呢!?)
感謝各位前輩幫忙!!!

Links booklink

Contact Us: admin [ a t ] ucptt.com