资源描述
#define B(x,y) pRGB240 + 3 * (x) + MyBmpInfo-biWidth * (y)#define G(x,y) pRGB241 + 3 * (x) + MyBmpInfo-biWidth * (y)#define R(x,y) pRGB242 + 3 * (x) + MyBmpInfo-biWidth * (y)#define Bay(x,y) pBay(x) + MyBmpInfo-biWidth * (y)void CMyDlg:bayer_bilinear(BYTE *pBay, BYTE *pRGB24, int x, int y) float tmp;tmp=(UINT)Bay(x + 0, y + 1) + (UINT)Bay(x + 0, y - 1) / 2)*fratio_B;if(tmp255)tmp=255;B(x + 0, y + 0) = (BYTE)tmp;tmp=Bay(x + 0, y + 0)*fratio_G;if(tmp255)tmp=255;G(x + 0, y + 0) = (BYTE)tmp;tmp=(UINT)Bay(x - 1, y + 0) + (UINT)Bay(x + 1, y + 0) / 2)*fratio_R;if(tmp255)tmp=255;R(x + 0, y + 0) = (BYTE)tmp;/tmp=Bay(x + 0, y + 1)*fratio_B;if(tmp255)tmp=255;B(x + 0, y + 1) =(BYTE)tmp;tmp=( (UINT)Bay(x + 0, y + 0) + (UINT)Bay(x + 0, y + 2)+ (UINT)Bay(x - 1, y + 1) + (UINT)Bay(x + 1, y + 1) / 4)*fratio_G;if(tmp255)tmp=255;G(x + 0, y + 1) =(BYTE)tmp;tmp=(UINT)Bay(x + 1, y + 0) + (UINT)Bay(x - 1, y + 0)+ (UINT)Bay(x + 1, y + 2) + (UINT)Bay(x - 1, y + 2) / 4)*fratio_R;if(tmp255)tmp=255;R(x + 0, y + 1) =(BYTE)tmp ;/tmp=(UINT)Bay(x + 0, y + 1) + (UINT)Bay(x + 2, y + 1)+ (UINT)Bay(x + 0, y - 1) + (UINT)Bay(x + 2, y - 1) / 4)*fratio_B;if(tmp255)tmp=255;B(x + 1, y + 0) = (BYTE)tmp;tmp=(UINT)Bay(x + 0, y + 0) + (UINT)Bay(x + 2, y + 0)+ (UINT)Bay(x + 1, y - 1) + (UINT)Bay(x + 1, y + 1) / 4)*fratio_G;if(tmp255)tmp=255;G(x + 1, y + 0) = (BYTE)tmp;tmp=Bay(x + 1, y + 0)*fratio_R;if(tmp255)tmp=255;R(x + 1, y + 0) =(BYTE)tmp ;/tmp=( (UINT)Bay(x + 0, y + 1) + (UINT)Bay(x + 2, y + 1) / 2)*fratio_B;if(tmp255)tmp=255;B(x + 1, y + 1) =(BYTE)tmp;tmp=Bay(x + 1, y + 1)*fratio_G;if(tmp255)tmp=255;G(x + 1, y + 1) = (BYTE)tmp;tmp=( (UINT)Bay(x + 1, y + 0) + (UINT)Bay(x + 1, y + 2) / 2)*fratio_R;if(tmp255)tmp=255;R(x + 1, y + 1) =(BYTE)tmp;void CMyDlg:bayer_to_rgb24(BYTE *pBits, BYTE *pRGB24)int i, j;for (i = 0; i biWidth-2; i += 2)for (j = 1; j biHeight-2; j += 2)bayer_bilinear(pBits, pRGB24, i, j);
展开阅读全文