乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      RGB圖象縮放算法

       都贏888 2013-04-10

      RGB圖象縮放算法

      463人閱讀 評論(0) 收藏 舉報(bào)
      void  StretchColors(void* pDest, int nDestWidth, int nDestHeight, int nDestBits, void* pSrc, int nSrcWidth, int nSrcHeight, int nSrcBits)
      {
       //參數(shù)有效性檢查
       //ASSERT_EXP(pDest != NULL);
       //ASSERT_EXP((nDestBits == 32) || (nDestBits == 24));
       //ASSERT_EXP((nDestWidth > 0) && (nDestHeight > 0));
       
       //ASSERT_EXP(pSrc != NULL);
       //ASSERT_EXP((nSrcBits == 32) || (nSrcBits == 24));
       //ASSERT_EXP((nSrcWidth > 0) && (nSrcHeight > 0));
       
       //令dfAmplificationX和dfAmplificationY分別存儲水平和垂直方向的放大率
       double dfAmplificationX = ((double)nDestWidth)/nSrcWidth;
       double dfAmplificationY = ((double)nDestHeight)/nSrcHeight;
       
       //計(jì)算單個源位圖顏色和目的位圖顏色所占字節(jié)數(shù)
       const int nSrcColorLen = nSrcBits/8;
       const int nDestColorLen = nDestBits/8;
       
       //進(jìn)行圖片縮放計(jì)算
       for(int i = 0; i<nDestHeight; i++)      //處理第i行
        for(int j = 0; j<nDestWidth; j++)   //處理第i行中的j列
        {
         //------------------------------------------------------
         //以下代碼將計(jì)算nLine和nRow的值,并把目的矩陣中的(i, j)點(diǎn)
         //映射為源矩陣中的(nLine, nRow)點(diǎn),其中,nLine的取值范圍為
         //[0, nSrcHeight-1],nRow的取值范圍為[0, nSrcWidth-1],
         
         double tmp = i/dfAmplificationY;
         int nLine = (int)tmp;
         
         if(tmp - nLine > 0.5)
          ++nLine;
         
         if(nLine >= nSrcHeight)
          --nLine;
         
         tmp = j/dfAmplificationX;
         int nRow = (int)tmp;
         
         if(tmp - nRow > 0.5)
          ++nRow;
         
         if(nRow >= nSrcWidth)
          --nRow;  
         
         unsigned char *pSrcPos = (unsigned char*)pSrc + (nLine*nSrcWidth + nRow)*nSrcColorLen;
         unsigned char *pDestPos = (unsigned char*)pDest + (i*nDestWidth + j)*nDestColorLen;
         
         //把pSrcPos位置的前三字節(jié)拷貝到pDestPos區(qū)域
         *pDestPos++ = *pSrcPos++;
         *pDestPos++ = *pSrcPos++;
         *pDestPos++ = *pSrcPos++;
         
         if(nDestColorLen == 4)
          *pDestPos = 0;
        }

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多