c语言bmp分割对齐,BMP字节对齐问题

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

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);

是什么意思啊?求大佬指教,还有我想字节对齐应该再怎么操作?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值