0

I made a program that generated images, then I copied the code to a new project, but the Bitmap declaration show's this error message: Severity Code Description Project File Line Suppression State Error CS1069 The type name 'Bitmap' could not be found in the namespace 'System.Drawing'. This type has been forwarded to assembly 'System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' Consider adding a reference to that assembly. Bubble_generation E:\Programok\Bubble_generation\Bubble_generation\Program.cs
I also tried adding the system.drawing.dll manually, but even that didn't work. Here's a screenshot: https://i.stack.imgur.com/9c5qR.jpg , and here's the code:

using System;
using System.Linq;
using System.Collections.Generic;
using System.Drawing;
using System.IO;

namespace Bubble_generation
{
    class Program
    {

        static void Main(string[] args)
        {
            Bitmap image = new Bitmap("input.png");
            int r_mem = 0;
            int g_mem = 0;
            int b_mem = 0;
            Color color_mem;
            for (int w = 0; w < image.Width; w++)
            {
                for (int h = 0; h < image.Height; h++)
                {
                    r_mem = image.GetPixel(w, h).R;
                    g_mem = image.GetPixel(w, h).G;
                    b_mem = image.GetPixel(w, h).B;
                    color_mem = Color.FromArgb(r_mem, r_mem, r_mem);
                    image.SetPixel(w, h, color_mem);
                }
            }
            string time = System.DateTime.Now.ToString("HH_mm_ss");
            image.Save("output_" + time + ".png");
        }
    }
}

1 Answers1

2

If you are in console mode, you must add this framework assembly reference in the Referencessection of the project in the solution explorer:

System.Drawing

.NET Core and System.Drawing

https://www.nuget.org/packages/System.Drawing.Common/

  • I've added System.Drawing like this: Bubble_generation>Dependencies>Assemblies>System.Drawing, but it doesn't work this way either – Lőrinc Ottó Oct 09 '19 at 21:29
  • I don't understand what is `Bubble_generation>Dependencies`. Did you use the `Add reference` submenu item of the popup menu of the `References` section that is under the `Properties` in the project tree in the solution explorer? –  Oct 09 '19 at 21:30
  • Yes, I think: I've right clicked on Dependecies, the I clicked Add Reference, then it was empty, so I've clicked browse, after that I've searched for System.Drawing, then choose the one with .dll extension – Lőrinc Ottó Oct 09 '19 at 21:32
  • I added links in the answer. You must use the section `Assemblies/Framework` (GAC). Not dll import. –  Oct 09 '19 at 21:33
  • I don't find /Framework, but here's a screenshot https://imgur.com/a/UJCqypB aybe It helps better understanding the situation – Lőrinc Ottó Oct 09 '19 at 21:46
  • Ok. What is your Visual Studio version and the target (.NET Framework, .NET Core, .NET Standard...)? –  Oct 09 '19 at 21:48
  • I use VS2019, and .NET Core 2.1 – Lőrinc Ottó Oct 10 '19 at 15:52