M
Macin
Hi,
How to efficently divide big array into small arrays as showed below?
IN
xxxxxxxxxxxxxx xxxxx xxxxx xxxxx
xxxxxxxxxxxxxx xxxxx xxxxx xxxxx
xxxxxxxxxxxxxx ==>> xxxxx xxxxx xxxxx
xxxxxxxxxxxxxx
xxxxxxxxxxxxxx xxxxx xxxxx xxxxx
xxxxxxxxxxxxxx xxxxx xxxxx xxxxx
xxxxx xxxxx xxxxx
Here is a piece of code I`ve done but it takes a lot of calculations for
bigger bitmaps... Is there any posibility to optimize it to make it faster?
The task of this method is to copy a bitmap into 8x8 square 2d arrays and
return a list of those 2d arrays
public ArrayList podzielNaKwdaraty(Bitmap obraz, char aKolor)
{
ArrayList wartosciRGB = new ArrayList();
for (int l=0;l<wys;l+=8)
{
for (int k=0;k<szer;k+=8)
{
byte[,] temp = new byte[8,8];
for (int i = 0; i<8; i++)
{
for (int j = 0; j<8; j++)
{
if (i+l>obraz.Height-1 || j+k>obraz.Width-1)
temp[i,j]=0;
else
{
if (aKolor == 'R')
temp[i,j]=m_bitmap.GetPixel(j+k,i+l).R;
else if (aKolor == 'G')
temp[i,j]=m_bitmap.GetPixel(j+k,i+l).G;
else if (aKolor == 'B')
temp[i,j]=m_bitmap.GetPixel(j+k,i+l).G;
}
}
}
wartosciRGB.Add(temp);
}
}
return wartosciRGB;
}
How to efficently divide big array into small arrays as showed below?
IN
xxxxxxxxxxxxxx xxxxx xxxxx xxxxx
xxxxxxxxxxxxxx xxxxx xxxxx xxxxx
xxxxxxxxxxxxxx ==>> xxxxx xxxxx xxxxx
xxxxxxxxxxxxxx
xxxxxxxxxxxxxx xxxxx xxxxx xxxxx
xxxxxxxxxxxxxx xxxxx xxxxx xxxxx
xxxxx xxxxx xxxxx
Here is a piece of code I`ve done but it takes a lot of calculations for
bigger bitmaps... Is there any posibility to optimize it to make it faster?
The task of this method is to copy a bitmap into 8x8 square 2d arrays and
return a list of those 2d arrays
public ArrayList podzielNaKwdaraty(Bitmap obraz, char aKolor)
{
ArrayList wartosciRGB = new ArrayList();
for (int l=0;l<wys;l+=8)
{
for (int k=0;k<szer;k+=8)
{
byte[,] temp = new byte[8,8];
for (int i = 0; i<8; i++)
{
for (int j = 0; j<8; j++)
{
if (i+l>obraz.Height-1 || j+k>obraz.Width-1)
temp[i,j]=0;
else
{
if (aKolor == 'R')
temp[i,j]=m_bitmap.GetPixel(j+k,i+l).R;
else if (aKolor == 'G')
temp[i,j]=m_bitmap.GetPixel(j+k,i+l).G;
else if (aKolor == 'B')
temp[i,j]=m_bitmap.GetPixel(j+k,i+l).G;
}
}
}
wartosciRGB.Add(temp);
}
}
return wartosciRGB;
}