19,468
社区成员
发帖
与我相关
我的任务
分享
char* pvImage;//保存图像数据的一块区域
//因为转换后的destbmp图像是4通道的,而srcImg是3通道的,所以应该给destbmp多分配4/3
pvImage = (char*)malloc(srcImg->height*srcImg->widthStep*4/3+3);
int i=0;
for(int a=0;a<srcImg->height;a++)
{
for(int b=0;b<srcImg->width;b++)
{
pvImage[i]=srcImg->imageData[a*srcImg->widthStep+3*b];//b分量
pvImage[i+1]=srcImg->imageData[a*srcImg->widthStep+3*b+1];//g分量
pvImage[i+2]=srcImg->imageData[a*srcImg->widthStep+3*b+2];//r分量
pvImage[i+3]=0;//alpha通道置零
i+=4;
}