How to draw into a bitmap and then display this bitmap?

  • Thread starter Thread starter Markus Humm
  • Start date Start date
M

Markus Humm

Hello,

using CF 1.0 how to do the following:

- have some bitmap
- draw lines and text into it
- put it onto screen (as a whole with a fast copy
operation or similar)
- avoid drawing directly on the screen
- with measures available either in CF 1.0 or Win32
directly thus avoiding 3rd party libraries like
OpenNET CF or similar

Greetings

Markus
 
Hello,

using CF 1.0 how to do the following:

- have some bitmap
- draw lines and text into it
- put it onto screen (as a whole with a fast copy
operation or similar)
- avoid drawing directly on the screen
- with measures available either in CF 1.0 or Win32
directly thus avoiding 3rd party libraries like
OpenNET CF or similar

Greetings

Markus

You should be able to piece the code together yourself from MSDN and
the numerous .NET Compact Framework books on the market. The code below
is the simplest of examples.

Pen p = new Pen(Color.White);

Brush b = new SolidBrush(Color.White);

Font f = new Font("Arial", 10.0F, FontStyle.Bold);



// - have some bitmap
// - avoid drawing directly on the screen

Bitmap offscreenBmp = new Bitmap(@"\My Documents\My Pictures\Flower.jpg");



// - draw lines and text into it

Graphics g = Graphics.FromImage(offscreenBmp);

g.DrawLine(p, 0, 65, 240, 65);

g.DrawString("This is some text", f, b, 70, 50);



// - put it onto screen (as a whole with a fast copy

// operation or similar)

pictureBox1.Image = offscreenBmp;
 
Hello,

your solution works but is "slow like hell".
Any idea about that? Or how to obtain the HDC of the bitmap to use the
BitBlt functions from Win32 GDI API? under CF 1.0 this is not accessible
as such.

Greetings

Markus
 
Back
Top