MAUI 如何使用剪辑

huangapple go评论79阅读模式
英文:

MAUI how to use clip

问题

  1. 从磁盘加载图像并显示在屏幕上 -> 完成!
  2. 在图像上显示裁剪边界作为剪辑几何体 -> 完成!
  3. 保存图像和几何信息 -> 完成!
  4. 在另一页中的网格图像容器中放置。用图像裁剪结果填充容器 -> 问题!

是否有方法在不保存裁剪后的图像的情况下,只使用图像路径和剪辑几何体来完成这个任务?

英文:

Can any one one explain how to use clip geometry and imagesource/button etc in the next scenario:

  1. Load an image from disk and show on display -> DONE!
  2. Over the image show a crop bounds as a clip geometry -> DONE!
  3. Save the image and geometry -> DONE!
  4. On another page place in a grid image container. Fill the container with the IMAGE CROPPING RESULT -> PROBLEM!

Are there ways to do this without saving a cropped image, just using the image path and clip geometry????

答案1

得分: 3

是的,你可以使用“使用几何裁剪”。VisualElement类有一个Clip属性,类型为Geometry,它定义了元素内容的轮廓。当Clip属性设置为Geometry对象时,只有在Geometry区域内的部分才可见。

以下示例演示了如何将Geometry对象用作图像的裁剪区域:

<Image Source="monkeyface.png">
    <Image.Clip>
        <EllipseGeometry RadiusX="100"
                         RadiusY="100"
                         Center="180,180" />
    </Image.Clip>
</Image>
英文:

> Are there ways to do this without saving a cropped image, just using
> the image path and clip geometry????

Yes, you can use the Clip with a Geometry.

The VisualElement class has a Clip property, of type Geometry, that defines the outline of the contents of an element. When the Clip property is set to a Geometry object, only the area that is within the region of the Geometry will be visible.

The following example shows how to use a Geometry object as the clip region for an Image:

&lt;Image Source=&quot;monkeyface.png&quot;&gt;
    &lt;Image.Clip&gt;
        &lt;EllipseGeometry RadiusX=&quot;100&quot;
                         RadiusY=&quot;100&quot;
                         Center=&quot;180,180&quot; /&gt;
    &lt;/Image.Clip&gt;
&lt;/Image&gt;

huangapple
  • 本文由 发表于 2023年4月13日 18:02:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76004155.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定