ChrisVB2008 Posted February 9, 2009 Posted February 9, 2009 (edited) Hi all I wonder if anyone on here can help me? I have built an Application in VB2008 Express that lets you open an image and type text over the top of the Image. I can save the image no problem from within the program BUT how do i get the Text to Save itself with the Image at the same time. The Text i want to save is a Label which recieves input from a Textbox. This is the code for saving the image ..................................................... Dim savefiledialog1 As New SaveFileDialog Try savefiledialog1.Title = "Save File" savefiledialog1.FileName = "*.bmp" savefiledialog1.Filter = "Bitmap |*.bmp" If savefiledialog1.ShowDialog() = DialogResult.OK Then PictureBox1.Image.Save(savefiledialog1.FileName, System.Drawing.Imaging.ImageFormat.Bmp) End If Catch ex As Exception 'Do Nothing End Try End Sub End Class ......................................... any help would be great cheers ChrisVB2008 Edited February 9, 2009 by ChrisVB2008
mrwITch Posted February 15, 2009 Posted February 15, 2009 Hi all I wonder if anyone on here can help me? I have built an Application in VB2008 Express that lets you open an image and type text over the top of the Image. I can save the image no problem from within the program BUT how do i get the Text to Save itself with the Image at the same time. The Text i want to save is a Label which recieves input from a Textbox. This is the code for saving the image ..................................................... Dim savefiledialog1 As New SaveFileDialog Try savefiledialog1.Title = "Save File" savefiledialog1.FileName = "*.bmp" savefiledialog1.Filter = "Bitmap |*.bmp" If savefiledialog1.ShowDialog() = DialogResult.OK Then PictureBox1.Image.Save(savefiledialog1.FileName, System.Drawing.Imaging.ImageFormat.Bmp) End If Catch ex As Exception 'Do Nothing End Try End Sub End Class ......................................... any help would be great cheers ChrisVB2008 It's been ages since I've done any VB coding - so I'm not familiar with VB.Net etc The picturebox is not a container so your image and your Label?? are two seperate items (if you drag the picturebox does the Label move with it) - so you don't get a combined Image when you try to save - I think you'll need to change your code a bit Set the image as the background for a Panel Add the Label to the Panel - set the text for the label Now you need to figure out how to get the panel to return you an image of its contents - the Documentation for VBExpress is awful - haven't been able to find anything useful You should be able to get an Image from a Graphics having used Graphics.CopyFromScreen(coords of Panel) Hope this helps Let me know how you get on
ChrisVB2008 Posted February 16, 2009 Author Posted February 16, 2009 (edited) Hi mrwITch Thanks for the Info about my Problem. I have done a search on the Net and have put this same question on a couple of Programming Forums but you are the First one to actually give me something i can build on.. The Panel is being used as the container for the Images that get displayed by the program and the label is the Text container getting its input from the Textbox. If i move the panel then the label moves with it.. Cheers I will let you know how i get on:cool: Edited February 16, 2009 by ChrisVB2008
SYNACK Posted February 16, 2009 Posted February 16, 2009 The namespace that you are after for this is System.Drawing.Text here is a tutorial that goes through painting text to the form and then saving it as a file which should help: Drawing in ASP.NET 2.0 and VB.NET Here are a few others: VB.NET - Draw Text on Image VB Helper: HowTo: Draw text filled with text in VB .NET Or if you want to be fancy you can use the XNA framework which is more suited to games type content if thats where your app is heading: VB.NET XNA Extra Tutorial - Display Text on Screen - www.alanphipps.com
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now