如主题所述,我有一张图片:
private Image testing;
testing = new Bitmap(@"sampleimg.jpg");
我想将其拆分为 3 x 3 矩阵,总共 9 张图像并保存。有任何提示或技巧可以做到这一点吗?我正在使用 Visual Studios 2008 并在智能设备上工作。尝试了一些方法,但我无法得到它。这是我尝试过的:
int x = 0;
int y = 0;
int width = 3;
int height = 3;
int count = testing.Width / width;
Bitmap bmp = new Bitmap(width, height);
Graphics g = Graphics.FromImage(bmp);
for (int i = 0; i < count; i++)
{
g.Clear(Color.Transparent);
g.DrawImage(testing, new Rectangle(0, 0, width, height), new Rectangle(x, y, width, height), GraphicsUnit.Pixel);
bmp.Save(Path.ChangeExtension(@"C\AndrewPictures\", String.Format(".{0}.bmp",i)));
x += width;
}