zoukankan      html  css  js  c++  java
  • 完善ImageStone中的图片裁切

    注: 前阵时在做一个在线图片处理的ActiveX控件,用到了黎叔的的开源项目"ImageStone",很不错,在这里还要感谢黎叔. 帮我实现了大部份功能 ,由于客户需要裁切功能,黎叔在代码中并没有去实现.我又去Google一下也没找到合适的(MSDN上也没找到关于GDI+关于图片裁切处理的VC版本..NET的到是找了一个).无耐,自已实现吧,现在把部份代码贴出来共 享一下.
     1inline void FCObjImage::Cropping(RECT reCropping) 
     2    if (!IsValidImage() || (reCropping.right <= 0|| (reCropping.bottom <= 0)) 
     3         return;
     4    if((int)reCropping.right==Width()&&(int)reCropping.bottom==Height())
     5         return;
     6    int nNewWidth = (int)(reCropping.right - reCropping.left);
     7    int nNewHeight = (int)(reCropping.bottom - reCropping.top); 
     8
     9    // first backup image const FCObjImage imgOld(*this) ;
    10    if (!Create (nNewWidth, nNewHeight, imgOld.ColorBits())) {
    11        assert(false) ; 
    12        return ; 
    13     }
     
    14     
    15     // duplicate palette
    16     if (ColorBits() <= 8
    17         CopyPalette (imgOld) ;
    18     
    19    const int nSpan = ColorBits() / 8 ;
    20
    21    for (int y=reCropping.top ; y < reCropping.bottom ; y++{
    22          BYTE * pPixel = GetBits (y-reCropping.top) ;
    23          for (int x=reCropping.left ; x < reCropping.right ; x++
    24                 BYTE * pOld = imgOld.GetBits(x,y); 
    25                 FCColor::CopyPixel (pPixel, pOld, nSpan) ;
    26                 pPixel += nSpan ; 
    27         }

    28      }
     
    29}

    30
  • 相关阅读:
    将不确定变为确定~接口应该是什么
    架构,改善程序复用性的设计~目录(附核心原代码)
    php实战第二十五天
    java一道简单的括号匹配问题
    屈原坐上神十带来了iOS 7
    《别独自用餐》 警句摘录
    php实战第二十四天
    偷了世界的程序员
    变故
    “快排”笔记
  • 原文地址:https://www.cnblogs.com/apexchu/p/740709.html
Copyright © 2011-2022 走看看