對不起,我不知道如何設置一個主題,可以表達我需要什麼幫助。一種列出字節數組像素值的方法
我有一個字節數組,位圖中每個像素的值。它是從左到右的一維數組。它佔用每行並將其添加到數組索引的末尾。
我想分割一個位圖爲225(= 15 * 15)件。每塊磚具有例如尺寸34×34,並且陣列的長度爲260×100(= 225×34×34)。所以就像你現在看到的那樣,我們需要15塊寬度和高度的磚塊。
幾個月前我從0-14開始使用兩個循環。我寫了自己的長代碼來獲得所有這些34x34磚塊。但是我沒有使用任何存儲所有值的數組。
現在我有一個一維數組,因爲帶位鎖的元帥副本和位圖數據是將所有像素的值快速複製到數組的最佳方法。
而是我站在面對面與問題如何得到那麼34元一排低,另外一個知道在35水平將有自己的初始值的另一塊磚..
PS。編輯我的帖子,如果事情不好。
很少有人會說「首先製作任何測試代碼」。我嘗試過,但我得到的只是垃圾,我真的不知道該怎麼做。
此方法用於將圖像裁剪爲包含磚塊的較小圖像。但我不希望存儲磚的小圖像。我需要存儲在字節數組中的值。
下,有一個證明。
private void OCropImage(int ii, int jj, int p, int p2)
{
////We took letter and save value to binnary, then we search in dictionary by value
this.rect = new Rectangle();
this.newBitmap = new Bitmap(this.bitmap);
for (ii = 0; ii < p; ii++)
{
for (jj = 0; jj < p2; jj++)
{
////New bitmap
this.newBitmap = new Bitmap(this.bitmap);
////Set rectangle working area with letters
this.rect = new Rectangle(jj * this.miniszerokosc, ii * this.miniwysokosc, this.miniszerokosc, this.miniwysokosc);
////Cut single rectangle with letter
this.newBitmap = this.newBitmap.Clone(this.rect, this.newBitmap.PixelFormat);
////Add frame to rectangle to delet bad noise
this.OAddFrameToCropImage(this.newBitmap, this.rect.Width, this.rect.Height);
this.frm1.SetIm3 = (System.Drawing.Image)this.newBitmap;
////Create image with letter which constains less background
this.newBitmap = this.newBitmap.Clone(this.GetAreaLetter(this.newBitmap), this.newBitmap.PixelFormat);
////Count pixels in bitmap
this.workingArea = this.GetBinnary(this.newBitmap);
var keysWithMatchingValues = this.alphabetLetters.Where(x => x.Value == this.workingArea).Select(x => x.Key);
foreach (var key in keysWithMatchingValues)
{
this.chesswords += key.ToString();
}
}
this.chesswords += Environment.NewLine;
var ordered = this.alphabetLetters.OrderBy(x => x.Value);
}
}
PS2。對不起我的英文,如果需要的話請糾正。
你真正的問題是什麼? – misha