BGRA与BGR的相互转换

 1 BGRA转BGR
 2 void BgraToBgr(BYTE *bgraData,int *bgraSize)
 3 {
 4     for(int i=0,j=0; j<*bgraSize; i+=3,j+=4)
 5     {
 6         *(bgraData+i) = *(bgraData+j);
 7         *(bgraData+i+1) = *(bgraData+j+1);
 8         *(bgraData+i+2) = *(bgraData+j+2);
 9     }
10     *bgraSize = *bgraSize/4*3;
11 }
12  
13 BGR转BGRA
14 void BgrToBgra(BYTE **bgrData,int *bgrSize)
15 {
16     int bgraSize = *bgrSize/3*4;
17     BYTE *bgraData = new BYTE[bgraSize];
18     for(int i=0, j=0; j < bgraSize; i+=3, j+=4)
19     {
20         *(bgraData+j) = *(*bgrData+i);
21         *(bgraData+j+1) = *(*bgrData+i+1);
22         *(bgraData+j+2) = *(*bgrData+i+2);
23         *(bgraData+j+3) = 0;
24     }
25     free(*bgrData);
26     *bgrData = bgraData;
27     *bgrSize = bgraSize;
28 }

 

转载于:https://www.cnblogs.com/jiu0821/p/9113027.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值