0

CLIを使用しているそのImage^クラスの厳密な名前空間が見つかりません。そのサイトはhttp://msdn.microsoft.com/en-us/library/aa970689.aspxからのものです。問題は、マイクロソフトが私がインポートすると思われるものを公開していないことです。そのため、彼らがどのクラスを考えているのかさえわかりません。

この作品(画像クラス)を作るために何を追加すると思いますか?

Error   1   error C3083: 'Controls': the symbol to the left of a '::' must be a type    C:\Users\Duke\Documents\Visual Studio 2010\Projects\Jpg\Jpg\Jpg.cpp 9   1   Jpg
Error   2   error C2039: 'Image' : is not a member of 'System::Windows' C:\Users\Duke\Documents\Visual Studio 2010\Projects\Jpg\Jpg\Jpg.cpp 9   1   Jpg
Error   3   error C2871: 'Image' : a namespace with this name does not exist    C:\Users\Duke\Documents\Visual Studio 2010\Projects\Jpg\Jpg\Jpg.cpp 9   1   Jpg

    #include "stdafx.h"
    #include "Form1.h"
    #using <mscorlib.dll> //requires CLI
    using namespace System;
    using namespace System::IO;
    using namespace System::Windows::Media::Imaging;
using namespace System::Windows::Controls::Image;
        Stream^ imageStreamSource = gcnew FileStream("C:\Users\Duke\Desktop\heart.jpg", FileMode::Open, FileAccess::Read, FileShare::Read);

                JpegBitmapDecoder^ decoder = gcnew JpegBitmapDecoder(imageStreamSource, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default);
                BitmapSource^ bitmapSource = decoder->Frames[0];//< --mamy bitmape
                // Draw the Image
                Image^ myImage = gcnew Image();
                myImage->Source = bitmapSource;
                myImage->Stretch = Stretch::None;
4

2 に答える 2

0

WICクラス(BitmapDecoderおよびなど)を使用している場合は、すべて古い学校のGDIである名前空間に関連するものはすべてBitmapSource避けたいと思うでしょう。ディレクティブでSystem::Drawingこれらの名前空間を参照しないか、名前空間全体を明示的に使用してください。usingSystem::Windows::Media

Imageあなたが求めている特定のクラスはおそらくSystem::Windows::Controls::Image(ドキュメントはこちら)です。

適切なDLLにリンクするには、プロジェクトにWICラッパーといくつかのサポートアセンブリへの参照を追加する必要があります。

  • PresentationCoreには、必要なすべての主要な画像コーデックと操作クラスがあります。これについては、JpegBitmapDecoderドキュメントに記載されています。
  • WindowsBaseは、WICラッパー(FreezableおよびDispatcherObject)によって使用されるいくつかの追加の依存関係に必要です。
  • System.Xamlも依存関係として発生する可能性があります...ここにあるWICを使用するC#プロジェクトでは、そのアセンブリなしでビルドすると、がないためにエラーが発生します System.Windows.Markup.IUriContext。ただし、これはWICアセンブリを使用した結果である可能性があります(ただし、XamlもIUriContextも使用していません)。
  • PresentationFrameworkは、適切なドキュメントImageに記載されているように、クラスとその依存関係を提供します
于 2012-11-21T15:18:49.457 に答える
0

System :: Windows :: Controls名前空間(Imageクラスの場合)には参照としてPresentationFramework.dllが必要であり、System :: Windows :: Media :: Imaging(BitmapSourceクラスの場合)名前空間にはPresentationCore.dllが必要です。

これらの2つの参照をプロジェクトに含めましたか?

于 2012-11-22T07:52:14.027 に答える