zoukankan      html  css  js  c++  java
  • 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);

    }

    //未完待续

  • 相关阅读:
    sublime
    C++两种字符串传参构造函数
    Navicat 导入Excel与增加主键
    5,做一个用户登录之后查看学员信息的小例子
    4,Flask 中的 request
    3,Flask 中的模板语言 Jinja2 及 render_template 的深度用法
    2,Flask 中的 Render Redirect HttpResponse
    1,flask简介
    11,手动绘制散点图的背景颜色
    10,knn手写数字识别
  • 原文地址:https://www.cnblogs.com/libing64/p/2878773.html
Copyright © 2011-2022 走看看