输入图像描述,代码如下:
#using < system.drawing.dll>
using namespace System;
using namespace System::Drawing;
protected:
virtual Void Form1::OnPaint(PaintEventArgs ^ pe) override
{
Graphics ^ g = pe->Graphics;
Image ^ image = Image::FromFile("SampleImage.jpg");
Form::ClientSize = image->Size;
g->DrawImage(image, 0, 0, image->Size.Width, image->Size.Height);
}
错误文本为"#using"需要c++/CLI模式"
添加编译指示
在tasks.json中添加/clr
选项之一:
- 在顶部文件行添加
#pragma managed
:#pragma managed #using < system.drawing.dll> // ...
- 在tasks.json中添加
/clr
到args