对不起,我不知道如何设置一个主题,可以表达我需要什么帮助。一种列出字节数组像素值的方法
我有一个字节数组,位图中每个像素的值。它是从左到右的一维数组。它占用每行并将其添加到数组索引的末尾。
我想分割一个位图为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