• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆 - 2, 文章 - 73, 評(píng)論 - 60, 引用 - 0
            數(shù)據(jù)加載中……

            S60 3rd下的圖像處理

              以下代碼是網(wǎng)上一位仁兄的, 但是我使用測(cè)試,怎么都不能得到正確的圖像, 我使用的16位的位圖, 安裝他的步驟無法成功, 圖像花屏. 有沒有高手告知一二, 如何解決這個(gè)問題. 

              inline TUint8 GetR( const TUint16 aColor)
              {
              return aColor>>8;
              }

              inline TUint8 GetG(const TUint16 aColor)
              {
              return aColor;
              }

              inline TUint8 GetB(const TUint16 aColor)
              {
              return aColor & 0xf;
              }

            CFbsBitmap* CinfoshowContainer::BmpZoomL( CFbsBitmap* aBitmap, TInt aWinth, TInt aHeight)
            {
             if( aWinth>0 && aHeight>0 )
             {
              const TInt widtha = aBitmap->SizeInPixels().iWidth;
              const TInt heighta = aBitmap->SizeInPixels().iHeight;
              TReal WPencent=(TReal)aWinth/widtha;
              TReal HPencent=(TReal)aHeight/heighta;
              return BmpZoomL( aBitmap, WPencent, HPencent);
             }
             else
             {
              return NULL;
             }

            }
            CFbsBitmap* CinfoshowContainer::BmpZoomL( CFbsBitmap* aBitmap, TReal aPencent ){
             if(aPencent>0)
             {
              return BmpZoomL( aBitmap, aPencent, aPencent );

             }
             else
             {
              return NULL;
             }
            }
            CFbsBitmap* CinfoshowContainer::BmpZoomL( CFbsBitmap* aBitmap, TReal aWPencent, TReal aHPencent)
            {
             if( aWPencent>0 && aHPencent>0 )
             {
             
              const TInt widtha = aBitmap->SizeInPixels().iWidth;
              const TInt heighta = aBitmap->SizeInPixels().iHeight;
              const TInt width = widtha * aWPencent +0.5;
              const TInt height = heighta * aHPencent +0.5;
              CFbsBitmap* newbitmap = new(ELeave) CFbsBitmap();
              User::LeaveIfError(newbitmap->Create(TSize(width,height), EColor4K/*displayMode*/));

              TBitmapUtil bmpUtil1(aBitmap);
              TBitmapUtil bmpUtil2(newbitmap);
              bmpUtil1.Begin(TPoint(0,0));
              bmpUtil2.Begin(TPoint(0,0), bmpUtil1); 
              
              TUint16* const addr1 = (TUint16*)aBitmap->DataAddress();
              TUint16* const addr2 = (TUint16*)newbitmap->DataAddress();
                 
              TUint16* p1 = addr1;     
              TUint16* p2 = addr2;     
              const TInt line1 = CFbsBitmap::ScanLineLength(widtha, EColor4K) / 2; 
              const TInt line2 = CFbsBitmap::ScanLineLength(width, EColor4K) / 2;     

              TReal xa=0,ya=0;
              TInt x=0,y=0;
              const TInt jump = line2 - width;

              TUint16* p2end = addr2 + width;

              p2end = addr2 + line2*height;
              while( p2 < p2end)
              {
               TUint16* p2endline = p2 + width;
               while( p2!=p2endline )
               {
                
                xa=x/aWPencent;
                ya=y/aHPencent;
                TInt xai = xa;
                TInt yai = ya;
                
                if( xai == widtha -1 )
                {
                 if( yai == heighta-1 )
                 {
                  *p2 = *(addr1+line1*yai+xai);
                 }
                 else
                 {
                  p1=addr1+line1*yai+widtha-1;     
                  
                  TUint8 red=GetR(*p1)+(GetR(*(p1+line1))-GetR(*p1))*(ya-yai)+0.5;  
                  TUint8 green=GetG(*p1)+(GetG(*(p1+line1))-GetG(*p1))*(ya-yai)+0.5;
                  TUint8 blue=GetB(*p1)+(GetB(*(p1+line1))-GetB(*p1))*(ya-yai)+0.5;
                  *p2 = (red<<8) | (green&0xf0) | blue;
                 }

                }
                else
                {
                 if( yai == heighta-1 )
                 {
                  p1=addr1+line1*(heighta-1)+xai;

                  TUint8 red=GetR(*(p1))+(GetR(*(p1+1))-GetR(*(p1)))*(xa-xai)+0.5;  
                  TUint8 green=GetG(*(p1))+(GetG(*(p1+1))-GetG(*(p1)))*(xa-xai)+0.5;
                  TUint8 blue=GetB(*(p1))+(GetB(*(p1+1))-GetB(*(p1)))*(xa-xai)+0.5;
                  *p2 = (red<<8) | (green&0xf0) | blue;
                 }
                 else
                 {
                  
                  p1=addr1+line1*yai+xai;
                  
                  TUint8 red1=GetR(*(p1))+(GetR(*(p1+1))-GetR(*(p1)))*(xa-xai)+0.5;  
                  TUint8 green1=GetG(*(p1))+(GetG(*(p1+1))-GetG(*(p1)))*(xa-xai)+0.5;
                  TUint8 blue1=GetB(*(p1))+(GetB(*(p1+1))-GetB(*(p1)))*(xa-xai)+0.5;
                  
                  p1=addr1+line1*(yai+1)+xai;
                  
                  TUint8 red2=GetR(*(p1))+(GetR(*(p1+1))-GetR(*(p1)))*(xa-xai)+0.5;  
                  TUint8 green2=GetG(*(p1))+(GetG(*(p1+1))-GetG(*(p1)))*(xa-xai)+0.5;
                  TUint8 blue2=GetB(*(p1))+(GetB(*(p1+1))-GetB(*(p1)))*(xa-xai)+0.5; 
                  
                  TUint8 red=red1+(red2-red1)*(ya-yai)+0.5;  
                  TUint8 green=green1+(green2-green1)*(ya-yai)+0.5;
                  TUint8 blue=blue1+(blue2-blue1)*(ya-yai)+0.5;
                  
                  *p2 = (red<<8) | (green&0xf0) | blue;
                  
                 }
                 
                }
                x++;
                p2++;
                
               }
               x=0;
               y++;
               p2+=jump;
               
              }

              bmpUtil2.End();
              bmpUtil1.End();
              
              return newbitmap;
             }
             else
             {
              return NULL;
             }
            }
             

            使用雙線性插值算法實(shí)現(xiàn),支持12位色,缺點(diǎn)是當(dāng)縮放比例小于0.5時(shí)圖像較源圖偏右下明顯。
            包含3個(gè)重載函數(shù),分別是指定寬高,指定整體縮放比例和指定

            可改為支持16位和24位色
            16位色RGB的獲取和合成,tempcolor為象素點(diǎn)的顏色值TUint16型

            TUint8 red= tempcolor>>8;
            TUint8 green=tempcolor>>3;
            TUint8 blue=tempcolor & 0x1f;

            tempcolor=((TUint16)(red&0xf8)<<8) | ((TUint16)(green&0x3f)<<3) | (blue&0x1f);


            24位色為3個(gè)字節(jié),指針為TUint8*,新圖像顏色計(jì)算公式示例如下
            *p2=(*p1)+((*(p1+line1))-(*p1))*(ya-yai)+0.5; //red
            p1++;
            p2++;
            *p2=(*p1)+((*(p1+line1))-(*p1))*(ya-yai)+0.5; //green
            p1++;
            p2++;
            *p2=(*p1)+((*(p1+line1))-(*p1))*(ya-yai)+0.5;//blue
            p1++;
            p2++;

            posted on 2007-11-14 11:41 郭天文 閱讀(969) 評(píng)論(0)  編輯 收藏 引用 所屬分類: S60

            国产日韩久久久精品影院首页| 伊人久久大香线蕉综合热线| 久久精品99久久香蕉国产色戒| 久久精品亚洲一区二区三区浴池 | 亚洲精品国产自在久久| 欧美大战日韩91综合一区婷婷久久青草 | 国内高清久久久久久| 欧美va久久久噜噜噜久久| 国产精品久久久久久久久鸭| 国产激情久久久久影院小草| 日批日出水久久亚洲精品tv| 久久精品国产99久久久古代| 久久精品国产91久久综合麻豆自制 | 久久高潮一级毛片免费| 精品久久久久久久国产潘金莲 | 日韩一区二区久久久久久 | 久久精品国产亚洲av高清漫画 | 国产精品永久久久久久久久久| 久久久久久久久66精品片| 久久99国产精一区二区三区| 日本高清无卡码一区二区久久| 久久男人Av资源网站无码软件| 久久九九久精品国产免费直播| 国产人久久人人人人爽| 欧美伊人久久大香线蕉综合69| 青青草原1769久久免费播放| 久久综合给久久狠狠97色| 久久久久久精品免费免费自慰| 久久综合狠狠色综合伊人| 亚洲第一极品精品无码久久| 精品久久久一二三区| 久久91精品国产91久| 欧美精品丝袜久久久中文字幕 | 久久精品无码专区免费青青| 久久久这里只有精品加勒比| 久久九九久精品国产| 99热成人精品免费久久| 国产一级做a爰片久久毛片| 久久久久无码精品国产| 天堂久久天堂AV色综合| 亚洲国产精品一区二区久久hs|