想达到的效果是。两张图片重叠。鼠标在第一张上面滑动,鼠标滑过的地方变为透明能看到下面的一张。请问如何去动态的修改图片单个像素的透明度啊。。先谢谢啦。

解决方案 »

  1.   

    lz的要求确实很麻烦,不好弄,先搜索一些Brush方面的资料吧,我感觉得用Polyline + ImageBrush这类的东西来做,具体我也没试过。
      

  2.   


    问一个问题。pictureBox透明问题怎么解决呀。我现在像素问题解决了,可是像素透明了以后 pictureBox这个控件不透明。。郁闷。
      

  3.   


    <Window x:Class="WpfApp.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="810" Width="972">
        <Canvas Name="canvas1" Background="#FF3E3D3D">
            <Image Canvas.Left="90" Canvas.Top="12" Name="image1" Stretch="Fill"  MouseLeftButtonDown="image1_MouseLeftButtonDown" SnapsToDevicePixels="True" MouseMove="image1_MouseMove" MouseLeftButtonUp="image1_MouseLeftButtonUp" MouseLeave="image1_MouseLeave" />
        </Canvas>
    </Window>using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;namespace WpfApp
    {
        /// <summary>
        /// MainWindow.xaml 的交互逻辑
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
                this.image1.Source = wb;
            }
            WriteableBitmap wb = new WriteableBitmap(new BitmapImage(new Uri(@"C:\Users\Administrator\Desktop\WpfApp\WpfApp\sunset.png")));        bool f = false;
            private void image1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
            {
                f = true;
            }
            private static byte[] _colorArray = new byte[16] { 245, 255, 255, 0, 245, 255, 255, 0, 245, 255, 255, 0, 245, 255, 255, 0 };        private void image1_MouseMove(object sender, MouseEventArgs e)
            {
                if (f)
                {
                                    Point pt = e.GetPosition(this.image1);                if (pt.X > wb.Width)
                    {
                        return;
                    }                if (pt.Y > wb.Height)
                    {
                        return;
                    }
                    wb.WritePixels(new Int32Rect((int)pt.X, (int)pt.Y, 2, 2), _colorArray, 8, 0);
                    this.image1.Source = wb;
                }
            }        private void image1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
            {
                f = false;
            }        private void image1_MouseLeave(object sender, MouseEventArgs e)
            {
                f = false;
            }
        }
    }