BGRA与BGR的相互转换

 1 BGRA转BGR
 2 void BgraToBgrBYTE *bgraData,int *bgraSize)
 3 {
 4     forint 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 BgrToBgraBYTE **bgrData,int *bgrSize)
15 {
16     int bgraSize = *bgrSize/3*4;
17     BYTE *bgraData = new BYTE[bgraSize];
18     forint 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 }

Published by

风君子

独自遨游何稽首 揭天掀地慰生平

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注