【问题标题】:How to change color of transparent image?如何更改透明图像的颜色?
【发布时间】:2015-06-18 06:14:05
【问题描述】:

我有一些黑白的透明图像。我想使用颜色选择器更改这些透明图像的颜色。我该怎么做。

  <Image  x:Name="img" HorizontalAlignment="Left" Stretch="Fill"  Width="50" Height="50"  Margin="148,263,0,375"   >
        </Image>
      <c4fToolkit:ColorPicker x:Name="picker" Height="200" 
             Width="200" ColorChanged="picker_ColorChanged"  Margin="270,283,10,245" Opacity="0.5" />

.cs 代码是

private void picker_ColorChanged(object sender, System.Windows.Media.Color color)
{
    tattoo.Source = new SolidColorBrush(color);
}

【问题讨论】:

  • 是否可以选择将光栅图像转换为矢量路径?

标签: c# xaml windows-phone-8


【解决方案1】:

您可以将图像包含在堆栈面板或网格中并设置其背景

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="100"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <StackPanel Background="Aqua" Height="100" Width="100" Grid.Row="0">
    <Image Name="img" Source="Assets/StoreLogo.scale-240.png" Height="100" Width="100"/>
    </StackPanel>
</Grid>

【讨论】:

  • 对不起,我无法理解你想表达的意思
  • 你不能改变图像的背景颜色。这就是为什么将透明图像保留在堆栈面板中并更改其背景颜色的原因。因为图像是透明的,它会反映您设置的颜色。
  • 您也可以通过 CS 代码更改 stackpannel 背景颜色
  • 当然。只需设置堆栈面板名称并在后面的代码中使用它。
猜你喜欢
  • 2014-02-01
  • 2011-11-29
  • 2017-06-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-12
  • 2011-06-02
相关资源
最近更新 更多