locked
How to write text at the bottom of the image? Please help. RRS feed

  • Question

  • User1989204087 posted

    Hi,

    I hope you can help. I like to know is it possible to write text at the bottom of an image.

    I have these solutions in mind :

    1. Let say I have an image of size 2" x 2" (inch), I will create an canvas of size 2"x 4" and place the image on it and write text after the image.

    But how to create canvas? and how to write text after the image?

     

    2. Create a big canvas of size 2"x4" to contain the 1) image of size 2"x2" and 2) plain canvas of 2"x2" for text.

    How to create the big canvas and place the above 1 and 2 onto it??

     

    Normally, how to write text on image where I want on the image?

    please help.

     

     

     

    Thursday, March 16, 2006 8:54 PM

All replies

  • User1109032460 posted

    You need to create a Graphics object over a Bitmap of the appropriate size and then use the DrawImage and DrawString methods to render the output. In outline terms, this would yield

    Dim b As New Bitmap( width, height )
    Dim g As Graphics = Graphics.FromImage( b )

    ...

    g.DrawImage( 2by2Bitmap, ... )
    g.DrawString( "Text", ... )

    Don't forget to call Dispose() on the Bitmap and Graphics objects that you create when you're finished with them.

    (Replace the bits in italics with appropriate values/variables and the ... sections with appropriate parameters)

    Thursday, March 16, 2006 9:07 PM
  • User1989204087 posted

    Thank you DMW,

    Dim b As New Bitmap( width, height )
    Dim g As Graphics = Graphics.FromImage( b )

    ...

    g.DrawImage( 2by2Bitmap, ... )
    g.DrawString( "Text", ... )

     

    This code works.  But the question is how to I set the new canvas object with background color white??

    Dim b as New Bitmap("Test.jpg")

    Dim Canvas as new Bitmap( Test.jpg's width, Test.jpg's Height + 30)

    This Canvas is used to contain  b-image But  at the New Height (Test.jpg's height + 30) of this Canvas the color is BLACK....!!!

    I want to place some text at the New Height of this Canvas...

     

    Canvas contain :

    ------Begin point --       b-image

     

     

    -----End of b-image --   b-image

    at the new height :        Place some text.

    of canvas

    Please help.

     

     

     

     

     

    Saturday, March 18, 2006 9:03 PM
  • User-1372641848 posted
    This code works.  But the question is how to I set the new canvas object with background color white??

    Graphics.Clear method can set background color of bitmap.

    If g is your Graphics then g.Clear(Color.White) will make background white.

    Sunday, March 19, 2006 9:13 AM