码迷,mamicode.com
首页 > 其他好文 > 详细

《Focus On 3D Terrain Programming》中一段代码的注释三

时间:2014-12-13 23:03:28      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   io   ar   color   sp   for   on   

取自《Focus On 3D Terrain Programming》中的一段:
 1 //--------------------------------------------------------------
 2 // Name:          CIMAGE::LoadUncompressedTGA - private
 3 // Description:   Load an uncompressed targa (TGA)
 4 // Arguments:     None
 5 // Return Value:  A boolean variable: -true: TGA was loaded
 6 //                                    -false: TGA was not loaded
 7 //--------------------------------------------------------------
 8 bool CIMAGE::LoadUncompressedTGA( void )
 9 {
10   ........
11   ....
12   pTGAinfo.m_uiBytesPerPixel= m_uiBPP/8;
13   pTGAinfo.m_uiImageSize    = ( pTGAinfo.m_uiBytesPerPixel*m_uiWidth*m_uiHeight );
14 
15   //copy the image data
16   memcpy( m_ucpData, ucpFile, pTGAinfo.m_uiImageSize );
17 
18   //byte swapping ( optimized by Steve Thomas )
19   for( uiCSwap=0; uiCSwap<( int )pTGAinfo.m_uiImageSize; uiCSwap+=pTGAinfo.m_uiBytesPerPixel )
20   {
21     m_ucpData[uiCSwap]^= m_ucpData[uiCSwap+2]^=m_ucpData[uiCSwap]^= m_ucpData[uiCSwap+2];
22   }
23 
24   //the uncompressed TGA has been successfully loaded
25   return true;
26 }
===============
开开眼界,把BGR转换为RGB的交换代码,过于高大上了,直接操作的硬件,可以提高一定的速度,对大图片有用。
    m_ucpData[uiCSwap]^= m_ucpData[uiCSwap+2]^=m_ucpData[uiCSwap]^= m_ucpData[uiCSwap+2];

《Focus On 3D Terrain Programming》中一段代码的注释三

标签:des   style   blog   io   ar   color   sp   for   on   

原文地址:http://www.cnblogs.com/QQ122252656/p/4161897.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!