Re: Problems printing text on top of img
From: APG (arunprakash_g_at_hotmail.com)
Date: 05/13/04
- Next message: Bob Powell [MVP]: "Re: deployment of a .NET DLL"
- Previous message: Bob Powell [MVP]: "Re: Confused by the NameValueCollection"
- In reply to: mphanke: "Problems printing text on top of img"
- Next in thread: mphanke: "Re: Problems printing text on top of img"
- Reply: mphanke: "Re: Problems printing text on top of img"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 13 May 2004 17:30:17 +0530
Hi Martin,
The code snipped you refered in your post should work fine. Just that we
need to ensure the printing happens in the right order, like the image
first and the text next in our case.
Try the following code in a sample form button click event, with a valid
image bitmap. The text should appear on top of the image.
private void button1_Click(object sender, System.EventArgs e)
{
Graphics g = CreateGraphics();
Rectangle rect = new Rectangle(10, 10, 100, 100);
Bitmap b= new Bitmap(@"SampleImage.jpg");
g.DrawImage(b, rect);
g.DrawString("TEXT", new Font("Impact", 20), new SolidBrush(Color.Red),
new Point(10, 10));
}
I doubt if some other event causes invalidation of the canvas and the
text is printed before the image, just a thought. Have a relook at the
paint event of the canvas.
HTH,
APG.
mphanke wrote:
> Hi,
>
> I'm desperately trying to print a string on top of an image, but for
> whatever reason the images allways stays on top of my canvas! Is there
> some trick how to implement things?
>
> I call
>
> ev.graphics.drawimage(img, rect);
> ev.graphics.drawstring("mystring", ..., rect, ...);
>
> I can't really deal with this behavoir....
>
>
> Martin
- Next message: Bob Powell [MVP]: "Re: deployment of a .NET DLL"
- Previous message: Bob Powell [MVP]: "Re: Confused by the NameValueCollection"
- In reply to: mphanke: "Problems printing text on top of img"
- Next in thread: mphanke: "Re: Problems printing text on top of img"
- Reply: mphanke: "Re: Problems printing text on top of img"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|