[英]Drawing Pixels as Custom Shapes
我有一个源图像,我想使用http://notes.ericwillis.com/2009/11/pixelate-an-image-with-csharp/上的方法将其缩小为像素,并将每个像素绘制为一个实心圆,空心圆或正方形(每个实际像素在屏幕上应为15px左右)。
我能想到的唯一方法是通过使用颜色和形状(可能绑定到路径?)的DependancyProperties
创建每个像素作为usercontrol
。 从ItemsControl
派生的父UC会在其内部创建数百个此类像素UC。
这似乎是一场表演梦night。
编辑:给一些背景,这是为像素艺术生成的应用程序。 我需要将每个“像素”存储在具有X,Y和Color属性的数据库中。
这是实现这一目标的最佳方法吗?
性能实际上是非常令人印象深刻的。 我用一个UserControl
(根),具有DependancyProperty
为精灵和ItemsControl
与multibinding。 MultiValueConverter
会将美术作品的点转换为Path
元素,并考虑画布的大小:
<ItemsControl>
<ItemsControl.ItemsSource>
<MultiBinding Converter="{StaticResource dotToPixelConverter}">
<Binding Path="Sprite.Beads" ElementName="root"/>
<Binding Path="Sprite.Width" ElementName="root"/>
<Binding Path="Sprite.Height" ElementName="root"/>
<Binding Path="ActualWidth" ElementName="root"/>
<Binding Path="ActualHeight" ElementName="root"/>
</MultiBinding>
</ItemsControl.ItemsSource>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.