Re: How to draw into a bitmap and then display this bitmap?
On 2008-07-08 10:02:16 +0100, Markus Humm said:
> 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;
--
Neil Cowburn MVP
Principal Partner
OpenNETCF Consulting
date: Tue, 8 Jul 2008 11:24:21 +0100
author: Neil Cowburn neilc@[nospam]opennetcf.[nospam]com