search

Home  >  Q&A  >  body text

c++ - 如何用IPicture保存指定区域?

  1. 一个非GUI(vc++)程序对图片进行处理,处理完成后获得某个区域比如(x,y,width,heigh),想保存这个区域为本地图片,该如何做?

怪我咯怪我咯2805 days ago626

reply all(1)I'll reply

  • 怪我咯

    怪我咯2017-04-17 14:00:07

    The main function of IPicture is the render function, which can redraw any area of ​​the screen. Controls, windows, etc. can be abstracted as CDC (device context), then CImage also belongs to CDC, so just draw the area on CImage.

    CImage image;
    image.Create( weight, height, 32 );//指定image的大小参数
    pPic->Render( image.GetDC(), 0, 0, weight, height, x, hmHeight - y, w, 0 - h, NULL );//参数为自己需要的区域。注意:要了解一下render图像是从左下角开始的,然后参数涉及矩阵的运算
    image.Save( "D:\abc.jpg" );
    image.ReleaseDC();

    reply
    0
  • Cancelreply