解决方案 »
- 为什么这样无法显示非对话框?
- 怎样获取控制台程序中显示的字符串?
- 求助:图象句柄的获取
- 关于一个OCX的回调问题,高手请进,200分
- VC中如何调用dll(高分赠送)解决后请说出需要的分数
- 急,急,急!!硬盘分区表损坏,又不能重新分区(有重要数据)
- 我想在IE浏览器上添加一个自己的按钮(点击这个按钮的时候会弹出用VC写好的exe),但是想每次打开IE浏览器的时候这个exe自动运行,也即模仿,这个按钮被默认按下。
- 文字图像的识别
- Doc-View中调用EXCEL问题
- 在vb\atl中如何设置,使得自己的函数参数有缺省值,或成为可选项
- 关于在桌面上用TextOut输出文字遇到的不能透明和两次有重叠的问题
- 求助:VC向WORD文档插入图片失败(急!!!)
2.新建一个GDIPlus::Bitmap对象,指定宽度、高度
3.基于Bitmap创建一个GDIPlus::Graphics对象
4.创建一个GDIPlus::Region对象,可以设置为圆形(用在第5步)
5.调用GDIPlus::Graphics的Clip方法,设置剪切区域
6.画出原图片
7.新的Bitmap保存到内存或文件(GDIPlus::Bitmap::Save)
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(®ion);
// 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.
--------------------------------------------------------------------------------
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);
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();
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();