Solved

The format of the bitmap is not supported

Posted on 2006-07-02
8
340 Views
Last Modified: 2013-12-03
Hi,

I have a 256 color bitmap image that's 14 X 14 pixels in size.  I used the following code to write a number between 1 and 99, and save it, to create 99 versions of the bitmap.  The images get created and look fine.  But when I call the following line, I get an exception.  It works fine for the stock image file (blank dot) which I use as a base.  But when any image I created is used, it throws an exception.

symbol = mpControl.ActiveMap.Symbols.Add( fileName );


Exception: "The format of the bitmap is not supported.  Bitmaps must be compressed and use 1, 4, 8 or 24 bit color."

What can I do differently to so that the 99 images I create will appear no different from the stock image?

Thanks,
Bob


for ( int number=1; number<=99; number++ )
{
string breadCrumbFileName = Preferences.ImagesDir + colorName + number.ToString() + ".bmp";
if ( handles.Utils.FileExists( fileName ) )
{
      Image outputImg = Image.FromFile(fileName);
      Bitmap outputBmp = new Bitmap(outputImg);
      Graphics g = Graphics.FromImage(outputBmp);

      // do something with "g"
      Font arial            = new Font( "Arial", 7 );
      Font arialBold      = new Font( arial, FontStyle.Bold );

      if ( number < 10 )
      {
            g.DrawString(number.ToString(), arialBold, Brushes.White, new PointF(3,1));
      }
      else
      {
            g.DrawString(number.ToString(), arialBold, Brushes.White, new PointF(0,1));
      }

      // release the graphics
      g.Dispose();

      // save the changes in the original fileName
      outputBmp.Save( breadCrumbFileName, System.Drawing.Imaging.ImageFormat.Bmp);
}

0
Comment
Question by:ba272
  • 5
  • 3
8 Comments
 

Author Comment

by:ba272
ID: 17028653
I suspect the problem involves the bit depth.  My prior raised that question.  But I don't know how to check that ot set that.
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 17029092
Try to replace last line with the following code:

// save the changes in the original fileName
//     outputBmp.Save( breadCrumbFileName, System.Drawing.Imaging.ImageFormat.Bmp);

Bitmap output24 = new Bitmap(outputBmp.Width, outputBmp.Height, PixelFormat.Format24bppRgb);
g = Graphics.FromImage(output24);
g.DrawImage(outputBmp, 0, 0);
g.Dispose();

output24.Save( breadCrumbFileName, System.Drawing.Imaging.ImageFormat.Bmp);

This code converts bitmap to 24 bpp format. Accorfing to error message, this must solve the problem.
0
 

Author Comment

by:ba272
ID: 17042458
Alex,

I am having trouble compiling.  PixelFormat could not be found.  I am using VS 2003.  What namespace is that?  WMEncoderLib does not work.

Bob
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 17042752
System.Drawing.Imaging Namespace
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:ba272
ID: 17043050
Thanks.  It works.  But that presented a new problem.

I write the digits as white, but apparently it's transparent, because many are hard to read because of there they end up on a map.

Any idea how to make this non-transparent?


Thanks,
Bob
0
 

Author Comment

by:ba272
ID: 17043106
I'd like the text I am writing in the circle and the circle to be non-transparent.  But I'd like the four corners to be transparent.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 17043144
I don't know what are requirements of the control you are working with, maybe there is transparent color property, which is set to white.
0
 

Author Comment

by:ba272
ID: 17044041
that's okay.  You got me over the big hump.

Bob
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now