解决方案 »

  1.   

    1.GDIPlus载入原图片
    2.新建一个GDIPlus::Bitmap对象,指定宽度、高度
    3.基于Bitmap创建一个GDIPlus::Graphics对象
    4.创建一个GDIPlus::Region对象,可以设置为圆形(用在第5步)
    5.调用GDIPlus::Graphics的Clip方法,设置剪切区域
    6.画出原图片
    7.新的Bitmap保存到内存或文件(GDIPlus::Bitmap::Save)
      

  2.   

    可以建立坐标系吧,根据x^2+y^2<=R^2公式,遍历图片,时间复杂度也不高O(n)。当然最后的图像边缘肯定不会理想,所以还是看楼上的答案吧!
      

  3.   

    Clipping with a Region --------------------------------------------------------------------------------One of the properties of the Graphics class is the clipping region. All drawing done by a given Graphics object is restricted to the clipping region of that Graphics object. You can set the clipping region by calling the SetClip method.The following example constructs a path that consists of a single polygon. Then the code constructs a region based on that path. The address of the region is passed to the SetClip method of a Graphics object, and then two strings are drawn. Hide Example// Create a path that consists of a single polygon.
    Point polyPoints[] = {Point(10, 10), Point(150, 10), 
       Point(100, 75), Point(100, 150)};
    GraphicsPath path;
    path.AddPolygon(polyPoints, 4);
    // Construct a region based on the path.
    Region region(&path);
    // Draw the outline of the region.
    Pen pen(Color(255, 0, 0, 0));
    graphics.DrawPath(&pen, &path);
    // Set the clipping region of the Graphics object.
    graphics.SetClip(&region);
    // Draw some clipped strings.
    FontFamily fontFamily(L"Arial");
    Font font(&fontFamily, 36, FontStyleBold, UnitPixel);
    SolidBrush solidBrush(Color(255, 255, 0, 0));
    graphics.DrawString(L"A Clipping Region", 20, &font, 
       PointF(15, 25), &solidBrush);
    graphics.DrawString(L"A Clipping Region", 20, &font, 
       PointF(15, 68), &solidBrush);
    The following illustration shows the clipped strings.
    --------------------------------------------------------------------------------
      

  4.   

    1.将图像选进一个dcfrom 中
    2.建立一个与dcfrom一样大的dcto;
    3.HRGN hRgn = ::CreateEllipticRgn(left,top,right,bottom);
      ::SelectClipRgn(dcto,hGn);//限制dcto上的绘制区域。只能在正方形的内切圆内绘制
    4.BitBlt函数从dcfrom复制到dcto,完事
    5.恢复和释放
    ::SelectClipRgn(dcto,NULL);
    ::Deleteobject(hRgn);
      

  5.   

    试了一下还真的可以,这是代码:
    CImage a;
    a.Load("C:\\Documents and Settings\\All Users\\Documents\\My Pictures\\示例图片\\Winter.jpg"); int w = a.GetWidth();
    int h = a.GetHeight(); CImage b;
    b.Create(w,h,24,0); HDC dc0 = a.GetDC();
    HDC dc1 = b.GetDC(); HRGN hGn = ::CreateEllipticRgn(0, 0 ,w,h);
    int nm = ::SelectClipRgn(dc1,hGn);

    ::BitBlt(dc1,0,0,w,h,dc0,0,0,SRCCOPY); ::SelectClipRgn(dc1,NULL);//恢复----将整个dc的全部区域作为绘制区域
    ::DeleteObject(hGn); b.Save("C:\\Documents and Settings\\All Users\\Documents\\My Pictures\\示例图片\\0.png");
    a.ReleaseDC();
    b.ReleaseDC();
      

  6.   

    double fZoomFactor = 3.0;//放大率
    CImage a;//原图
    a.Load("C:\\Documents and Settings\\All Users\\Documents\\My Pictures\\示例图片\\Winter.jpg"); int w = a.GetWidth();
    int h = a.GetHeight(); CImage b;//长宽各放大fZoomFactor后的、经过椭圆裁剪的图
    b.Create(fZoomFactor*w,fZoomFactor*h,24,0); HDC dca = a.GetDC();
    HDC dcb = b.GetDC(); HRGN hGn = ::CreateEllipticRgn(0, 0 ,fZoomFactor*w,fZoomFactor*h);
    int nm = ::SelectClipRgn(dcb,hGn);//裁剪 ::SetStretchBltMode(dcb,HALFTONE);
    ::StretchBlt(dcb,0,0,fZoomFactor*w,fZoomFactor*h,dca,0,0,w,h, +SRCCOPY); ::SelectClipRgn(dcb,NULL);//恢复----将整个dc的全部区域作为绘制区域
    ::DeleteObject(hGn); CImage c;//将放大后的图再缩小回原图大小--一放一缩之间图像插值算法就干预了
    c.Create(w,h,24,0);
    HDC dcc = c.GetDC();
    ::SetStretchBltMode(dcc,HALFTONE);
    ::StretchBlt(dcc,0,0,w,h,dcb,0,0,fZoomFactor*w,fZoomFactor*h, +SRCCOPY);
    c.Save("C:\\Documents and Settings\\All Users\\Documents\\My Pictures\\示例图片\\0.png"); c.ReleaseDC();
    a.ReleaseDC();
    b.ReleaseDC();