Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a 500x700 canvas, have an image on top of it...

 

I want to find where the image ends on the canvas and add a line of text to the bottom ...images can be of different height and width

 

I tried to use Height of canvas, height of image , subtract...but i dont think that would work because i need the values in pixels...not sure...

 

This is what i have-

Dim strFileToConvert As String

       strFileToConvert = "C:\source2.Tif"
       'Initialize the bitmap object by supplying the image file path
       Dim b As New Bitmap(strFileToConvert)
      [b] Dim Canvas As New Bitmap(500, 700) [/b]

       Dim g As Graphics = Graphics.FromImage(b)
       Dim gr As Graphics = Graphics.FromImage(Canvas)

       'get size of the image
     [b]  Dim ImageHieght = b.Height()
       Dim CanvasHeight = Canvas.Height() [/b]

       Dim bgBrush = New SolidBrush(System.Drawing.Color.White)

       gr.FillRectangle(bgBrush, New Rectangle(0, 0, 500, 700))
       gr.DrawImage(b, 0.0F, 0.0F)

             Dim copy As Font = New Font("Times New Roman", 9, FontStyle.Regular)


       gr.DrawString("Copyright © 1994-2004 Test ", copy, Brushes.Black, 10.0F, 350.0F)
      
       Canvas.Save(strFileToConvert + ".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg)
       Canvas.Dispose()

 

any ideas on how i can find out where the height of the image ends?

  • Leaders
Posted

What's wrong with

Convert.ToSingle(b.Height)

?

It has always returned height in pixels for me. :)

Also, use & for string concatenation in VB instead of +.

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...