该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
unsigned char *imagedata = NULL; //动态分配存储原图片的像素信息的二维数组
unsigned char *imagedataCut = NULL;//动态分配存储裁剪后的图片的像素信息的二维数组
char readPath[] = "AA.bmp";
readBmp(readPath);
imagedata = pBmpBuf;
//===========================================图片裁剪处理====================================================//
int leftdownx, leftdowny, rightupx, rightupy;//用户输入数值
int Rleftdownx, Rleftdowny, Rrightupx, Rrightupy;//转换成实际可以使用数值
//cout << "请输入要裁剪的矩形区域(正向)的左上角和右下角的坐标:" << endl;
leftdownx = 70;
leftdowny = 343;
rightupx = 590;
rightupy = 592;
int CutWidth, CutHeight;
CutWidth = Rrightupx - Rleftdownx;//矩形框实际宽度
CutHeight = Rrightupy - Rleftdowny;//矩形框实际高度
int lineByte;
int lineByte2;
lineByte = (CutHeight * biBitCount / 8 + 3) / 4 * 4;
lineByte2 = (CutWidth * biBitCount / 8 + 3) / 4 * 4;//字节对齐
imagedataCut = new unsigned char[lineByte2 * lineByte];
imagedata = imagedata + (Rleftdowny) * bmpWidth * 3 ;
//----------------------------裁剪区域数据提取-------------------------------------------//
for (int i = 0; i < CutHeight; i++)
{
for (int j = 0; j < CutWidth; j++){
for (int k = 0; k < 3; k++){
*(imagedataCut + i * lineByte2 + j * 3 + k) = *(imagedata + i * bmpWidth * 3 + j * 3 + k + Rleftdownx*3);
}
}
}
其中代码里面:
*(imagedataCut + i * lineByte2 + j * 3 + k) = *(imagedata + i * bmpWidth * 3 + j * 3 + k + Rleftdownx*3);
是什么意思啊?求大佬指教,还有我想字节对齐应该再怎么操作?