Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Load/Save Bitmaps

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cdvolko@gmail.com - 02 Mar 2008 18:57 GMT
Hi,

I'm looking for code to load and save bitmap files (24 bit per pixel).

TIA
Claus
Fredo - 02 Mar 2008 19:13 GMT
Have a look at System.Drawing.Bitmap and System.Drawing.Image.

> Hi,
>
> I'm looking for code to load and save bitmap files (24 bit per pixel).
>
> TIA
> Claus
cdvolko@gmail.com - 03 Mar 2008 13:57 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:

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]
>    }
> }
Roger Frost - 02 Mar 2008 19:17 GMT
> Hi,
>
> I'm looking for code to load and save bitmap files (24 bit per pixel).
>
> TIA
> Claus

Explore the options in System.Drawing.Bitmap Using those in combination with
System.IO will get you where you need to be.

Signature

Roger Frost
"Logic Is Syntax Independent"

Pinki - 02 Mar 2008 19:30 GMT
Bitmap image1;

image1 = new Bitmap(@"C:\Documents and Settings\All Users\"
           + @"Documents\My Music\music.bmp", true);

> Hi,
>
> I'm looking for code to load and save bitmap files (24 bit per pixel).
>
> TIA
> Claus
cdvolko@gmail.com - 03 Mar 2008 10:05 GMT

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.