Re: Problems printing text on top of img

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: APG (arunprakash_g_at_hotmail.com)
Date: 05/13/04


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



Relevant Pages

  • Re: Obstacles for Tcl/Tk commercial application development ?
    ... Lack of a good printing is a big problem. ... I just did some successful experimentation using the img::window extension, a Tk canvas, and the canvas2Photo routine by George Petasis detailed here: ... Wrap those images in simple HTML and save the HTML as a file with some JavaScript to bring up the printer dialog immediately: ... Essentially we're using the browser as a print preview but the printer dialog is also coming up immediately and we let the browser handle the complexities of printing. ...
    (comp.lang.tcl)
  • Re: array of labels or array of buttons
    ... I'd want the printing to work on any printer. ... hands you a canvas. ... > have its transparent property set to transparent. ... them in the constructor, ...
    (alt.comp.lang.borland-delphi)
  • Re: Converting a (big) canvas to an image
    ... However, if it were possible to convert the whole canvas to an image, ... fight with the Windows API to achieve what I'm after. ... of screenshots --either with what you found ... Printing on Windows: ...
    (comp.lang.tcl)
  • Re: printing under MS win
    ... | works just fine (to a user-selected file, or an "lpr" device specified ... I'm printing PostScript (the default from a canvas). ...
    (comp.lang.python)