0

在下面的程序中,我收到以下错误:

error C2143: syntax error : missing ';' before '->'  
error C2143: syntax error : missing ';' before '->' 

任何猜测我做错了什么?

#include "stdafx.h"
#include <stdio.h>
#using <system.drawing.dll>
using namespace System;
using namespace System::Drawing;
int main()
{       
Image^ newImage = Image::FromFile( "SampImag.jpg" );
// Create parallelogram for drawing image.
Point ulCorner = Point(100,100);
Point urCorner = Point(325,100);
Point llCorner = Point(150,250);
array<Point>^ destPara = {ulCorner,urCorner,llCorner};
// Create rectangle for source image.
Rectangle srcRect = Rectangle(50,50,150,150);
GraphicsUnit units = GraphicsUnit::Pixel;
// Draw image to screen.
    //Graphics1 = new Graphics();  
     Graphics->DrawImage( newImage, destPara, srcRect, units );
   return 0;
 }
4

1 回答 1

0

问题是您只能在 Graphics 类的实例上调用 DrawImage。

但问题是 Graphics 类是一个抽象类,并且控制台应用程序没有关联的 Graphics 对象。这篇 MSDN 文章提供了一些有关如何使用 Graphics 类的信息。首先使用 Graphics 类创建一个工作 C# 控制台应用程序,然后将其转换为 C++/CLI。这将是解决此问题的更简单方法。

如果允许,请尝试使用 VS 2012 创建 C++/CLI 应用程序,因为它为 C++/CLI 项目提供智能感知。

于 2012-11-11T05:33:39.053 回答