2011-07-01 9 views
0

私はいくつかのクラスを含むクラスライブラリを作成しました。 イメージクラスのインスタンスを作成するには、どのアセンブリリファレンスを追加する必要がありますか? これは、C#を使用してVisual Studio 2010で作成されたWPFアプリケーションです。イメージクラス(C#、WPF)のインスタンスを作成するには、どのアセンブリリファレンスを追加する必要がありますか?

誰かが興味があれば、私のコードが続きます。

ありがとうございます! (System.Drawing.Imageのように) はAnders Branderud

/// <summary> 
    /// Create an image with certain image address and return it. 
    /// </summary> 
    /// <param name="imageAddress">Name of image file without jpg ending.</param> 
    /// <returns></returns> 
    ///<remarks>Adapted code from Microsoft-website</remarks> 
    public static BitmapImage CreateAndDisplayImage(string imageAddress) 
    { 
     // Create Image Element 
     Image myImage = new Image(); 
     myImage.Width = 200; 

     // Create source 
     BitmapImage myBitmapImage = new BitmapImage(); 



     myBitmapImage.BeginInit(); 
     //Image address 
     Uri relativeUri = new Uri(IMAGE_DIRECTORY + imageAddress + ".jpg", UriKind.Relative); 
     myBitmapImage.UriSource = relativeUri; 



     // IMAGE_DIRECTORY + "/" 
     // To save significant application memory, set the DecodePixelWidth or 
     // DecodePixelHeight of the BitmapImage value of the image source to the desired 
     // height or width of the rendered image. If you don't do this, the application will 
     // cache the image as though it were rendered as its normal size rather then just 
     // the size that is displayed. 
     // Note: In order to preserve aspect ratio, set DecodePixelWidth 
     // or DecodePixelHeight but not both. 
     myBitmapImage.DecodePixelWidth = 200; 
     myBitmapImage.EndInit(); 
     //set image source 
     return myBitmapImage; 

}

答えて

0

イメージ抽象的です。代わりにそれから派生するビットマップ(System.Drawing.Bitmap)を使用してください。理由が何であれ、あなたはBitmapの独自の実装を行っています。