Solved

The format of the bitmap is not supported

Posted on 2006-07-02
8
346 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 48

Expert Comment

by:AlexFM
ID: 17042752
System.Drawing.Imaging Namespace
0
 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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…

803 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