1

I'm working on a school project using the Monogame API and I'm pretty new to c#.

I have seen examples of people using a Graphics class to draw on a bitmap. However, when I've tried to do that I get "The type or namespace name 'Graphics' could not be found".

        Bitmap bmp = Bitmap.CreateBitmap(50,50, Bitmap.Config.Argb4444);
        Graphics g = Graphics.FromImage(bmp);
aWindyEnd
  • 11
  • 5

1 Answers1

0

I managed to use Graphics in mono by adding a reference to the drawing library in my csproj file:

<ItemGroup>
// other references
<PackageReference Include="System.Drawing.Common" Version="4.5.1" />
// other references
</ItemGroup>

After adding the refrence to your csproj file, just remeber to restore your project for the reference to be loaded. You can do this by running the terminal command dotnet restore inside your project directory.

nobody
  • 1,144
  • 1
  • 10
  • 20