- 论坛徽章:
- 0
|
我们图像是16位的,a:r:g:b = 1:5:5:5,如果是24位的,则要在r、g、b的分量处理上改动一下
- unsigned int PtAR=0,PtBR=0,PtCR=0,PtDR=0,PixelValueR=0;//源A、B、C、D四点像素R值
- unsigned int PtAG=0,PtBG=0,PtCG=0,PtDG=0,PixelValueG=0;//源A、B、C、D四点像素G值
- unsigned int PtAB=0,PtBB=0,PtCB=0,PtDB=0,PixelValueB=0;//源A、B、C、D四点像素B值
- register unsigned SpixelColNum=0,SpixelRowNum=0,DestCol=0,DestRow=0;
- unsigned int SpixelColAddr=0,SpixelRowAddr=0;
- unsigned int ColDelta=0,RowDelta=0,scaleV=0,scaleH=0;
- unsigned int ContribAandBR=0,ContribCandDR=0;//ContribAandBR:源A、B两点像素R的插值,其他类似
- unsigned int ContribAandBG=0,ContribCandDG=0;
- unsigned int ContribAandBB=0,ContribCandDB=0;
- unsigned short SColor, DColor; //源、目的像素
- unsigned int _ContribTem[HOMESCREEN_WIDTH*3];
- int i=0;
- scaleH=(g_src_width<<8)/g_dsn_width;
- scaleV=(g_src_height<<8)/g_dsn_height;
-
- //first line
- for(DestCol=0;DestCol<g_dsn_width;DestCol++)
- {
- SpixelColAddr=DestCol*scaleH;
- ColDelta=SpixelColAddr&255;
- SpixelColNum=(SpixelColAddr-ColDelta)>>8;
- SColor = *(unsigned short *)GET_SRC_BUFFER_PTR(SpixelRowNum,SpixelColNum);
- PtAB=((SColor>>0)&0x1f);
- PtAG=((SColor>>5)&0x1f);
- PtAR=((SColor>>10)&0x1f);
- if((SpixelColNum+1)<g_src_width)
- {
- SColor = *(unsigned short *)GET_SRC_BUFFER_PTR(SpixelColNum+1,SpixelRowNum);
- PtBB=((SColor>>0)&0x1f);
- PtBG=((SColor>>5)&0x1f);
- PtBR=((SColor>>10)&0x1f);
-
- SColor = *(unsigned short *)GET_SRC_BUFFER_PTR(SpixelColNum,SpixelRowNum+1);
- PtCB=((SColor>>0)&0x1f);
- PtCG=((SColor>>5)&0x1f);
- PtCR=((SColor>>10)&0x1f);
- SColor = *(unsigned short *)GET_SRC_BUFFER_PTR(SpixelColNum+1,SpixelRowNum+1);
- PtDB=((SColor>>0)&0x1f);
- PtDG=((SColor>>5)&0x1f);
- PtDR=((SColor>>10)&0x1f);
- }
- else
- {
- PtBB=PtCB=PtDB=PtAB;
- PtBG=PtCG=PtDG=PtAG;
- PtBR=PtCR=PtDR=PtAR;
- }
- ContribAandBB=ColDelta*(PtBB-PtAB)+PtAB*256;
- ContribCandDB=ColDelta*(PtDB-PtCB)+PtCB*256;
- _ContribTem[i++]=ContribCandDB;
- PixelValueB=(ContribAandBB*256+(ContribCandDB-ContribAandBB)*RowDelta)>>16;
-
- ContribAandBG=ColDelta*(PtBG-PtAG)+PtAG*256;
- ContribCandDG=ColDelta*(PtDG-PtCG)+PtCG*256;
- _ContribTem[i++]=ContribCandDG;
- PixelValueG=(ContribAandBG*256+(ContribCandDG-ContribAandBG)*RowDelta)>>16;
-
- ContribAandBR=ColDelta*(PtBR-PtAR)+PtAR*256;
- ContribCandDR=ColDelta*(PtDR-PtCR)+PtCR*256;
- _ContribTem[i++]=ContribCandDR;
- PixelValueR=(ContribAandBR*256+(ContribCandDR-ContribAandBR)*RowDelta)>>16;
- DColor = (PixelValueR<<10) |(PixelValueG<<5) | (PixelValueB) | (0x8000);
- dest = (unsigned short*)GET_FBBUFFER_PTR(_myfb, DestRow, DestCol);
- *dest = DColor;
- }
- //////////other line//////////
- for(DestRow=1;DestRow< g_dsn_height;DestRow++)
- {
- i=0;
- SpixelRowAddr=DestRow*scaleV;
- RowDelta=SpixelRowAddr&255;
- SpixelRowNum=(SpixelRowAddr-RowDelta)>>8;
-
- for(DestCol=0;DestCol< g_dsn_width;DestCol++)
- {
- SpixelColAddr=DestCol*scaleH;
- ColDelta=SpixelColAddr&255;
- SpixelColNum=(SpixelColAddr-ColDelta)>>8;
- SColor = *(unsigned short *)GET_SRC_BUFFER_PTR(SpixelColNum,SpixelRowNum);
- PtAB=((SColor>>0)&0x1f);
- PtAG=((SColor>>5)&0x1f);
- PtAR=((SColor>>10)&0x1f);
-
- if(((SpixelColNum+1)<g_src_width)&&((SpixelRowNum+1)<g_src_height))
- {
- SColor = *(unsigned short *)GET_SRC_BUFFER_PTR(SpixelColNum,(SpixelRowNum+1));
- PtCB=((SColor>>0)&0x1f);
- PtCG=((SColor>>5)&0x1f);
- PtCR=((SColor>>10)&0x1f);
-
- SColor = *(unsigned short *)GET_SRC_BUFFER_PTR((SpixelColNum+1),SpixelRowNum+1);
- PtDB=((SColor>>0)&0x1f);
- PtDG=((SColor>>5)&0x1f);
- PtDR=((SColor>>10)&0x1f);
- }
- else
- {
- PtBB=PtCB=PtDB=PtAB;
- PtBG=PtCG=PtDG=PtAG;
- PtBR=PtCR=PtDR=PtAR;
- }
-
-
- ContribAandBB=_ContribTem[i];
- ContribCandDB=ColDelta*(PtDB-PtCB)+PtCB*256;
- _ContribTem[i++]=ContribCandDB;
- PixelValueB=(ContribAandBB*256+(ContribCandDB-ContribAandBB)*RowDelta)>>16;
- ContribAandBG=_ContribTem[i];
- ContribCandDG=ColDelta*(PtDG-PtCG)+PtCG*256;
- _ContribTem[i++]=ContribCandDG;
- PixelValueG=(ContribAandBG*256+(ContribCandDG-ContribAandBG)*RowDelta)>>16;
- ContribAandBR=_ContribTem[i];
- ContribCandDR=ColDelta*(PtDR-PtCR)+PtCR*256;
- _ContribTem[i++]=ContribCandDR;
- PixelValueR=(ContribAandBR*256+(ContribCandDR-ContribAandBR)*RowDelta)>>16;
- DColor = (PixelValueR<<10) |(PixelValueG<<5) | (PixelValueB) | (0x8000);
- dest = (unsigned short*)GET_FBBUFFER_PTR(_myfb, DestCol, DestRow);
- *dest = DColor;
- }
- }
-
复制代码 |
|