psychotomusSim
08-30-2006, 08:21 PM
How can I resize an image and draw text onto it? I have my image inside a picture box.
resize image and draw textpsychotomusSim 08-30-2006, 08:21 PM How can I resize an image and draw text onto it? I have my image inside a picture box. Cags 08-31-2006, 04:50 AM To resize an Image you will have to use a Graphics object. Same to draw a string. ' create destination image the right size Dim dest As New Bitmap(50, 50) ' load into graphics object Dim g As Graphics = Graphics.FromImage(dest) ' draw out image rescaled g.DrawImage(picBox1.Image, New Rectangle(0, 0, dest.Width, dest.Height), New Rectangle(0, 0, picBox1.Image.Width, picBox1.Image.Height), GraphicsUnit.Pixel) ' then use draw string to draw a string g.DrawString(...) psychotomusSim 08-31-2006, 11:53 AM Private Sub btnConvert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConvert.Click ' create destination image the right size Dim dest As New Bitmap(10, 10) ' load into graphics object Dim g As Graphics = Graphics.FromImage(dest) ' draw out image rescaled g.DrawImage(Pic.Image, New Rectangle(0, 0, dest.Width, dest.Height), New Rectangle(0, 0, Pic.Image.Width, Pic.Image.Height), GraphicsUnit.Pixel) End Sub where does it draw the new image at? it doesn't resize the image from pic into pic. Cags 08-31-2006, 12:31 PM Of course it doesn't alter the PictureBoxes image. The Graphics object draws to the Bitmap which it is created from (assuming your using the FromImage method, which in this case we are). If you wish to put the image back in the PictureBox you will have to set the Image property to the bitmap you drew to, which using the code I provided is dest. |
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum