备注:
下面D:\03.png是我用photoshop建立的一幅3*3的png图像,其中9个点的颜色分别是:赤橙黄黑白绿青蓝紫。
<Window x:Class="Test.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="700" Width="700"
        >
    <Grid>
        <TextBlock Name="TB"></TextBlock>
    </Grid>
</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 Test
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            BitmapImage bi = new BitmapImage(new Uri("D:\\03.png"));
            byte[] b = new byte[4 * bi.PixelWidth * bi.PixelHeight];
            Int32Rect rect = new Int32Rect(0, 0, bi.PixelWidth, bi.PixelHeight);
            bi.CopyPixels(rect, b, bi.PixelWidth * 4, 0);
            for (int i = 1; i <= bi.PixelHeight; i++)
            {
                for (int j = 1; j <= bi.PixelWidth; j++)
                {
                    int z = 4 * (i - 1) * bi.PixelWidth + 4 * (j - 1);                    this.TB.Text += (b[z + 0] + "、" + b[z + 1] + "、" + b[z + 2] + "、" + b[z + 3] + "、      ");
                }
                this.TB.Text += "\r\n";
            }
        }    }
}

解决方案 »

  1.   

    解决方法已经找到:
    使用如下方法,载入图片即可:            BitmapImage bi = new BitmapImage();
                bi.BeginInit();
                bi.CreateOptions = BitmapCreateOptions.IgnoreColorProfile;
                bi.UriSource = new Uri("D:\\03.png");
                bi.EndInit();
      

  2.   

    恩, BitmapImage即可。
    http://nonocast.cn/?p=2630
      

  3.   

    关键不是BitmapImage。
    关键是:
    BitmapCreateOptions.IgnoreColorProfile