VC6.0图像处理4--镜像

源码下载:http://download.csdn.net/detail/renshengrumenglibing/3875522

//本节是关于镜像处理的函数,大家重点关注如何申请存储空间,并返回一个指向该空间的指针,以及如何利用指针实现数据的操作

void CBMPViewerDoc::OnMenuitem32786() //垂直镜像
{
// TODO: Add your command handler code here
int linewidth;
linewidth=(pbi->bmiHeader.biWidth*pbi->bmiHeader.biBitCount+31)/32*4;

//申请空间,并返回其指针赋给lpbit

HLOCAL hbit;
hbit = LocalAlloc(LHND, linewidth);
unsigned char *lpbit;
lpbit = (unsigned char*)LocalLock(hbit);



unsigned char *lpScr;
unsigned char * lpDest;
// TODO: Add your command handler code here
for(int i = 0 ; i< bi.biHeight/2 ; i++){


lpScr = (unsigned char*)lpBuf + linewidth*i;
lpDest = (unsigned char*)lpBuf+linewidth*(bi.biHeight- 1 - i);

//常用的函数memcpy,将制定大下的数据从地址2复制个地址1

memcpy(lpbit, lpDest, linewidth);

memcpy(lpDest, lpScr,linewidth);
memcpy(lpScr, lpbit,linewidth);


}

// Invalidata(TRUE);
UpdateAllViews(NULL,0,NULL);
}

void CBMPViewerDoc::OnMenuitem32787() //水平镜像
{
// TODO: Add your command handler code here
// TODO: Add your command handler code here
int linewidth;
linewidth=(pbi->bmiHeader.biWidth*pbi->bmiHeader.biBitCount+31)/32*4;
unsigned char * lpDest;
unsigned char temp;

// TODO: Add your command handler code here
for(int i = 0 ; i< bi.biHeight ; i++){
for(int j = 0 ; j< bi.biWidth/2 ; j++){
unsigned char *lpScr;
lpScr = (unsigned char *)lpBuf+linewidth*(bi.biHeight - i -1) + j;
lpDest = (unsigned char *)lpBuf+linewidth*(bi.biHeight - i) - j;
temp = *lpScr;
*lpScr = *lpDest;
*lpDest = temp;

}

}



UpdateAllViews(NULL,0,NULL);

}

//未完待续

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值