在特定形状的.NET剪辑图像 [英] Clip an image in a specific shape .NET

查看:132
本文介绍了在特定形状的.NET剪辑图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MVC4项目中,用户可以使用文件上传控件添加其公司标志有一个页面。这些图像/标识,然后在地图上的移动应用程序中。我们需要裁剪这些图像,使它们看起来就像一个标志。

I have a page in my MVC4 project where user can add its company logo using the file upload control. These images/logos are then shown on map in mobile application. We need to crop these images so that they can look like a Flag.

在这里输入的形象描述

我们需要采取图像只把部分的标志框架内,离开休息。

We need to take only the part of image inside the flag frame and leave the rest.


  1. 可以使用它code在C#做什么?

  2. 如果是,如何是可以做到的。请帮我做一些code样品和链接。

  3. 我需要显示在上传的图片标志框架,使用户可以在该框架中调整自己的形象,它想做的是在框架中。

请与一些API和code样品给我建议。

Please suggest me with some APIs and code samples.

感谢。

更新:在一些网站,当我们上传个人资料图片,它让我们在上面的框架,我们已经选择的图像可以移动,使所需部分进入该帧。现在,当我们上传了个人资料图片,它被调整到该尺寸。我可以做同样的事情吗?在上面的框架,我可以给一个标志形状,用户可以将上传的图像,得到该帧图像所希望的部分。
这是正确的做法?
我们应该怎么做?我曾经看着一些jQuery code样品,但没有帮助。

Update: In some sites, when we upload profile image, it gives us a frame on top, and the image we have selected can be moved, so that the desired part comes into that frame. Now when we upload our profile image, it gets resized into that size. Can I do something similar here? in the frame above, I can give a flag shape, user can move the uploaded image, to get desired part of image in that frame. Is it right approach? How can we do this? I have looked into some jquery code samples, but no help.

推荐答案

您可以使用setClip的功能与该地区的参数:

You can use SetClip function with the Region as parameter:

https://msdn.microsoft.com /en-us/library/x1zb278e(v=vs.110).aspx

所以,你需要创建位图图形对象,设置剪辑的标志的形状,然后该Graphics对象上绘制图像。这就是全部。

So you need to create Graphics object from Bitmap, set clip with the shape of your flag and then draw image on that Graphics object. That's all.

这篇关于在特定形状的.NET剪辑图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆