I have the following code in which I am attempting to break a large
image up in 16x16 blocks and perform some processing on those blocks.
For debugging I would like to save each of the 16x16 blocks just to
see things working. The original image needs to stay preserved and not
changed through this function. If possible I need to take the graphics/
image object and save it back as a temporary bitmap in the system so I
can perform my image processing algorithms on it. I need to then save
the coordinates of each of these blocks. I stumped on how to make this
work and have been through many attempts...feel I am close but not
quite there yet. Advice would be great.
function xyz (Bitmap bmpSource, int width, int height)
{
int i, j;
for (y = 0; y < width; y++)
{
for (z = 0; z < height; z++)
{
Rectangle rSource = new Rectangle(y, z, 16, 16);
Rectangle rDest = new Rectangle(0, 0, 15, 15);
using (Graphics g = Graphics.FromImage(bmpSource))
{
g.DrawImage(bmpSource,rDest,rSource,GraphicsUnit.P ixel);
g.Save();
}
for (i = 0; i < y; i++)
{
for (j = 0; j < z; j++)
{
Color pixelColor = bmpSource.GetPixel(i,
j);
int r = pixelColor.R; // the Red component
int g = pixelColor.G; // the Green
component
int b = pixelColor.B; // the Blue
component
Color newColor = Color.FromArgb(r, g, b);
output.SetPixel(i, j, newColor);
output.Save(string.Format("C:\\temp\
\outputOF{0}X{1}.bmp", y, z));
}
}
z += 15;
}
y += 15;
}
}