469,329 Members | 1,489 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,329 developers. It's quick & easy.

problems saving a bitmap

Hi,
I'm trying to save a bitmap file so I can print it later. I have
Image.Save("sImage.bmp",System.Drawing.Imaging.Ima geFormat.Bmp);

The file sImage.bmp shows up in the bin\debug folder but when I try to print
it (or open it), it's completely black. I know Image is the correct picture
because when I immediately print it, it works. What am I doing wrong?

Thanks!
Melanie
Nov 17 '05 #1
4 2120
Melanie,

When you create the bitmap, how many bits per pixel are you setting it
for? I think by default, it uses 32 bpp, but most viewers can only handle
24 bpp. Change the settings on the bitmap (in code) and you should be able
to see it fine.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"melanieab" <me*******@discussions.microsoft.com> wrote in message
news:67**********************************@microsof t.com...
Hi,
I'm trying to save a bitmap file so I can print it later. I have
Image.Save("sImage.bmp",System.Drawing.Imaging.Ima geFormat.Bmp);

The file sImage.bmp shows up in the bin\debug folder but when I try to
print
it (or open it), it's completely black. I know Image is the correct
picture
because when I immediately print it, it works. What am I doing wrong?

Thanks!
Melanie

Nov 17 '05 #2
I suspect that you're drawing on the image with a black pen. Perhaps
creating a text bitmap?

When you create an image it will be a 32bit per pixel image with all the
pixel elements, including the alpha, set to zero. When saved this will look
like a black image. If you draw on it in black before saving it it will be
black ink on a black background (ie.. all black)

Before drawing on the image use the Graphics.Clear method to clear the image
to some sensible colour (white is good)

Then you'll see your image.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"melanieab" <me*******@discussions.microsoft.com> wrote in message
news:67**********************************@microsof t.com...
Hi,
I'm trying to save a bitmap file so I can print it later. I have
Image.Save("sImage.bmp",System.Drawing.Imaging.Ima geFormat.Bmp);

The file sImage.bmp shows up in the bin\debug folder but when I try to
print
it (or open it), it's completely black. I know Image is the correct
picture
because when I immediately print it, it works. What am I doing wrong?

Thanks!
Melanie

Nov 17 '05 #3
Hi again,
I'm actually not drawing on the bitmap, I'm capturing the screen of the
particular tabpage that I'm focused on. On the last tabpage, I have the
option of printing any of the previous four pages. My problem arises when I
load the form and don't focus on one of the screens I want to print (I have
an event that captures each screen as a bitmap when focus leaves). So when
I'm actually on a screen, I've been trying to save it to a file that can be
called some time in the future if the bitmap is null (hasn't been focused
on).
Any thoughts?
Thanks again!!!
Melanie

"Bob Powell [MVP]" wrote:
I suspect that you're drawing on the image with a black pen. Perhaps
creating a text bitmap?

When you create an image it will be a 32bit per pixel image with all the
pixel elements, including the alpha, set to zero. When saved this will look
like a black image. If you draw on it in black before saving it it will be
black ink on a black background (ie.. all black)

Before drawing on the image use the Graphics.Clear method to clear the image
to some sensible colour (white is good)

Then you'll see your image.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"melanieab" <me*******@discussions.microsoft.com> wrote in message
news:67**********************************@microsof t.com...
Hi,
I'm trying to save a bitmap file so I can print it later. I have
Image.Save("sImage.bmp",System.Drawing.Imaging.Ima geFormat.Bmp);

The file sImage.bmp shows up in the bin\debug folder but when I try to
print
it (or open it), it's completely black. I know Image is the correct
picture
because when I immediately print it, it works. What am I doing wrong?

Thanks!
Melanie


Nov 17 '05 #4
Check out the GDI+ FAQ. There is an article there that captures a screenshot
or a shot of a specific control.

Without seeing your own code I'd be hard-pressed to suggest a solution.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"melanieab" <me*******@discussions.microsoft.com> wrote in message
news:93**********************************@microsof t.com...
Hi again,
I'm actually not drawing on the bitmap, I'm capturing the screen of the
particular tabpage that I'm focused on. On the last tabpage, I have the
option of printing any of the previous four pages. My problem arises when
I
load the form and don't focus on one of the screens I want to print (I
have
an event that captures each screen as a bitmap when focus leaves). So
when
I'm actually on a screen, I've been trying to save it to a file that can
be
called some time in the future if the bitmap is null (hasn't been focused
on).
Any thoughts?
Thanks again!!!
Melanie

"Bob Powell [MVP]" wrote:
I suspect that you're drawing on the image with a black pen. Perhaps
creating a text bitmap?

When you create an image it will be a 32bit per pixel image with all the
pixel elements, including the alpha, set to zero. When saved this will
look
like a black image. If you draw on it in black before saving it it will
be
black ink on a black background (ie.. all black)

Before drawing on the image use the Graphics.Clear method to clear the
image
to some sensible colour (white is good)

Then you'll see your image.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"melanieab" <me*******@discussions.microsoft.com> wrote in message
news:67**********************************@microsof t.com...
> Hi,
> I'm trying to save a bitmap file so I can print it later. I have
> Image.Save("sImage.bmp",System.Drawing.Imaging.Ima geFormat.Bmp);
>
> The file sImage.bmp shows up in the bin\debug folder but when I try to
> print
> it (or open it), it's completely black. I know Image is the correct
> picture
> because when I immediately print it, it works. What am I doing wrong?
>
> Thanks!
> Melanie


Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Michael Kennedy [UB] | last post: by
reply views Thread by monfu | last post: by
3 posts views Thread by CSH | last post: by
reply views Thread by Christopher Kurtis Koeber | last post: by
2 posts views Thread by Map Reader | last post: by
1 post views Thread by M Keeton | last post: by
2 posts views Thread by Halimaji Nijazi | last post: by
5 posts views Thread by TheGanjaMan | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Purva khokhar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.