Solved

The format of the bitmap is not supported

Posted on 2006-07-02
8
343 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
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…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 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

16 Experts available now in Live!

Get 1:1 Help Now