472,337 Members | 1,439 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,337 software developers and data experts.

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 2206
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Michael Kennedy [UB] | last post by:
Hi Everyone, I have this multithreaded C# windows forms application which does a lot of image processing. Occasionally, I get the following...
0
by: monfu | last post by:
Dear all I have the following code:- System.Drawing.Image src_image = System.Drawing.Image.FromStream(imgStream); Bitmap bitmap = new...
3
by: CSH | last post by:
Hi all, I've run into a small problem opening and saving bitmaps. Concider the following code: Dim oBM as Bitmap Dim cFileName as String ...
0
by: Christopher Kurtis Koeber | last post by:
Dear All, I am having problems saving an image to a memory stream to use it in an API function. The error occurs in the save method of the bitmap....
2
by: Map Reader | last post by:
Greetings, I am converting an old VB6 application to use .NET. One of the old controls loads icons from the disk and displays them. However, the...
1
by: M Keeton | last post by:
I currently have a picture which is stored in a "System.Drawing.Image" variable and I want to save it as a bitmap file. I have tried 2 different...
2
by: Halimaji Nijazi | last post by:
Hi For viewing pictures I am using a pictures box... For making proper saving of the pic, I must delete an existing pic-file and overwrite it...
5
by: TheGanjaMan | last post by:
Hi everyone, I'm trying to write up a simple image stamper application that stamps the Exif date information from the jpegs that I've taken from...
9
by: kombu67 | last post by:
I'm reading a series of images from a MS SQL table and saving them to directory. These are staff ID pictures from our security card app. Once I've...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.