原理
图像的翻转有两种,一种是水平翻转,一种是垂直翻转。水平翻转会产生左右对调的图像,垂直翻转会产生上下对调的图像。
水平翻转代码
void ICETEKDM6437B2Mirror(unsigned char * src, unsigned char * dst, short nPixelsPerLines, short nDisWinWidth, short nDisWinHeight)
{
int mi,mj;
unsigned char *psrc,*pdst;
for(mj = 0 ; mj < nDisWinHeight ; mj++)
{
pdst = dst + nDisWinWidth * 2;
psrc = src;
for ( mi=0;mi {
pdst -= 4;
pdst[0] /* cr */ = *psrc++; /* cr */
pdst[3] /* y2 */ = *psrc++; /* y1 */
pdst[2] /* cb */ = *psrc++; /* cb */
pdst[1] /* y1 */ = *psrc++; /* y2 */
}
src += nPixelsPerLines * 2;
dst += nPixelsPerLines * 2;
}
}
垂直翻转代码
void ICETEKDM6437B2Mirror(unsigned char * src, unsigned char * dst, short nPixelsPerLines, short nDisWinWidth, short nDisWinHeight)
{
int mi,mj;
unsigned char *psrc,*pdst;
unsigned char string[720*2];//临时空间
for(mj = 0 ; mj < nDisWinHeight ; mj++)
{
psrc = src;
pdst = dst + (nDisWinHeight-mj-1) * nDisWinWidth * 2;
memcpy(string, psrc, nDisWinWidth * 2);
memcpy(psrc, pdst, nDisWinWidth * 2);
memcpy(pdst, string, nDisWinWidth * 2);
src += nPixelsPerLines * 2;
//dst += nPixelsPerLines * 2;
}
}
阅读(1009) | 评论(0) | 转发(0) |