我找不到我使用 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;