Have a look at System.Drawing.Bitmap and System.Drawing.Image.
> Have a look at System.Drawing.Bitmap and System.Drawing.Image.
I've done that. And I've written my program. But when trying to
compile it, I get the error CS0234: The type or namespace name Drawing
does not exist in the namespace system (Is an assembly reference
missing?). What's wrong? Here's my code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.IO;
namespace Border
{
class Program
{
static void Main(string[] args)
{
String filename;
Bitmap myBitmap;
Console.WriteLine("Source file name:");
filename = Console.ReadLine();
myBitmap = new Bitmap(filename);
if (myBitmap == null)
{
Console.WriteLine("Error: File not found!");
return;
}
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < myBitmap.Width; j++)
{
myBitmap.SetPixel(j, i, Color.Black);
myBitmap.SetPixel(j, myBitmap.Height - i,
Color.Black);
}
for (int j = 0; j < myBitmap.Height; j++)
{
myBitmap.SetPixel(i, j, Color.Black);
myBitmap.SetPixel(myBitmap.Width - i, j,
Color.Black);
}
}
myBitmap.Save(filename);
}
}
}
Roger Frost - 04 Mar 2008 21:04 GMT
>> Have a look at System.Drawing.Bitmap and System.Drawing.Image.
>
> I've done that. And I've written my program. But when trying to
> compile it, I get the error CS0234: The type or namespace name Drawing
> does not exist in the namespace system (Is an assembly reference
> missing?). What's wrong? Here's my code:
Yes, we should have mentioned this as well, all apologizes. Just because
your 'using' something doesn't mean your "including" (referencing) it, you
will need to manually add a reference to use the System.Drawing features as
well (at least the Bitmap namespace). If you are developing on a product in
the Microsoft Visual Studio family, you can right click your project in the
Solution Explorer, choose Add Reference... and select System.Drawing in the
.NET Tab.
If your IDE is some other brand, basically you need to reference
System.Drawing.dll
Most of the time you don't need to do this because the most common
Namespaces are included in mscorlib.dll and it is automatically referenced
in any new project you create. I guess System.Drawing.Bitmap isn't
considered "common."
Enjoy!

Signature
Roger Frost
"Logic Is Syntax Independent"
Fredo - 04 Mar 2008 21:06 GMT
You need to include a reference to the system.drawing assembly. Right click
the references section in Solution Explorer and add System.Drawing.
>> Have a look at System.Drawing.Bitmap and System.Drawing.Image.
>
[quoted text clipped - 48 lines]
> }
> }