uint32 *temp = (uint32*)GlobalAlloc(GMEM_FIXED, ( w * h * 4)); m_pBits = (uint32*)GlobalAlloc(GMEM_FIXED, ( w * h * 3));TIFFReadRGBAImage(tiff, w, h,temp, 0); int total = w * h; uint32 * final = m_dib->m_pBits; for (int i = 0 ; i< total ; i++ ){ memcpy( final,temp+(4*i)+3, 1);final++; memcpy( final,temp+(4*i)+2, 1);final++; memcpy( final,temp+(4*i)+1, 1);final++; }这样写怎末不行?
嵌入ASM调用BSWAP指令,然后取前三字节,这样效率比较高
我没有看错吧?ABGR转到RGB……很困难吗? 那我就随便写一点吧,汇编的 mov eax, ABGR and eax, 000000ffh mov ecx, ABGR and ecx, 00ff0000h mov edx, ABGR and edx, 0000ff00hshl eax, 16 shr ecx, 16 or eax, ecx or eax, edx
m_pBits = (uint32*)GlobalAlloc(GMEM_FIXED, ( w * h * 3));TIFFReadRGBAImage(tiff, w, h,temp, 0);
int total = w * h;
uint32 * final = m_dib->m_pBits;
for (int i = 0 ; i< total ; i++ ){
memcpy( final,temp+(4*i)+3, 1);final++;
memcpy( final,temp+(4*i)+2, 1);final++;
memcpy( final,temp+(4*i)+1, 1);final++;
}这样写怎末不行?
那我就随便写一点吧,汇编的
mov eax, ABGR
and eax, 000000ffh
mov ecx, ABGR
and ecx, 00ff0000h
mov edx, ABGR
and edx, 0000ff00hshl eax, 16
shr ecx, 16
or eax, ecx
or eax, edx