Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

The format of the bitmap is not supported

Posted on 2006-07-02
8
Medium Priority
?
360 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 2000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

783 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