我使用 WritebleBitmap 类成功地将画布添加到位图,然后尝试使用位图通过 SaveFileDilogue 将图像保存在客户端系统上。我正在使用 FluxJpegCore 图像编码的方法,我们使用光栅阵列来生成图像像素。下面是完成这项工作的代码部分。
byte[][,] raster = new byte[bands][,];
for (int i = 0; i < bands; i++)
{
raster[i] = new byte[width, height];
}
for (int row = 0; row < height; row++)
{
for (int column = 0; column < width; column++)
{
int pixel = bitmap.Pixels[width * row + column];
raster[0][column, row] = (byte)(pixel >> 16);
raster[1][column, row] = (byte)(pixel >> 8);
raster[2][column, row] = (byte)pixel;
}
}
图像保存一切正常,但是当我缩放图像然后打印它时,代码在“raster[i] = new byte[width, height];”行失败。引发系统内存不足错误。谁能帮我找到解决方案?