-2

So I am trying to draw an Image using CLR console application, using the .NET library. I found this code on https://msdn.microsoft.com/en-us/library/dbsak4dc(v=vs.110).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-2 ,but I dont know what arguments I have to use to run the DrawMyImage function

using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;


void DrawMyImage(PaintEventArgs^ e)
{
    Image^ newImage = Image::FromFile("picture.png");

    int x = 100;
    int y = 100;
    int width = 350;
    int height = 450;

    e->Graphics->DrawImage(newImage, x, y, width, height);
}

int main(array<System::String ^> ^args)
{
    DrawMyImage();

    return 0;
}

If there is any other easy way to display images from console application feel free to say.

Chris O
  • 5,017
  • 3
  • 35
  • 42
Goliat
  • 7
  • 1
  • 9
  • Where do you expect this to render? You're mixing console/forms applications at the moment. – Caramiriel Oct 24 '16 at 17:05
  • This does not belong to the `c++` tag (since it is not at all about standard c++). It should be `c++-cli` or similar. – drescherjm Oct 24 '16 at 17:08
  • I'm not sure, a new window with this image or image in the console (dont think it is possible). I want to make som kind of display that shows console outputs in some cooler way then just text. – Goliat Oct 24 '16 at 17:09
  • http://stackoverflow.com/questions/493536/can-one-executable-be-both-a-console-and-gui-application – pm100 Oct 24 '16 at 17:12

1 Answers1

1

What you're asking for doesn't make sense: A console application, by definition, runs within a console window. (That's the same window as if you run cmd in Windows.) You can output text there, nothing else.

PaintEventArgs is the name of an event arguments class within WinForms. It is used within a WinForms application, not within a console application. There is no console API that will give you an object of that type, nor is there any way for you to construct one that will do what you want.

If you want to draw your image using WinForms, make a WinForms application. And I highly recommend that you switch to C# for this: C++/CLI is not intended as a primary development language; it is intended for linking C# and C++ code. You'll make things easier on yourself if you switch to C# for this.

David Yaw
  • 27,383
  • 4
  • 60
  • 93