From: Peter Duniho on
On Wed, 07 Oct 2009 02:16:13 -0700, Alberto <alberto(a)nospam.es> wrote:

> [...]
> If I draw some pixels in the bitmap, they appear in the saved filed but
> not
> the lines draw firstly so I think that there is some problem with the
> DrawToBitmap method.

There is not a problem with the DrawToBitmap() method. Many people have
used it successfully to do exactly what you're trying to do (within the
limitations of the method...you should be aware that only those parts of
the control that are visible on the screen will get drawn to the bitmap).

More generally: the assumption that there is something wrong with the OS,
framework library, etc. should be the VERY last resort. Windows, .NET,
etc. are certainly not bug-free. But it's incredibly rare to find
something wrong in any of the basic functionality of the API.

In this particular case, a previous poster indicated that you are calling
CreateGraphics() to get the Graphics instance used to draw your lines. If
that's true, then that indeed is the problem. The only thing that will
appears in the Bitmap after you call DrawToBitmap() are the things that
are drawn during the Paint event, and only those things drawn into the
PaintEventArgs.Graphics instance of a Graphics object.

The previous poster provided alternative code that works, but your reply
suggested that you'd already written code like that and it didn't work.
Since I have no reason to believe the code he posted doesn't work, that
would leave two possibilities: you didn't actually try code like what he
posted, or when you tried it, it did work. Either way, that would mean
you're mistaken about something.

In my very first reply to your question, I hinted that you need to post
the actual code if you expect someone to be able to say specifically what
is wrong with your code. That continues to be true. And posting an
attachment isn't an appropriate way to do that...many ISPs don't even
allow attachments through, either stripping them from the post, or
blocking the post altogether, and attachments aren't archived by the
various Usenet archiving services, including Google Groups. Post a
concise-but-complete code example as text, as part of your message.

I suspect you've been given sufficient information already for you to find
a solution to the problem. But in any case, without a proper code
example, there's not very much point in trying to provide specific
advice. There's too much uncertainty about what's actually wrong with
your code, until you actually post the code.

Pete