+ Post New Thread
Results 1 to 4 of 4
Coding Thread, Saving Text in VB2008 as Picture File? in Coding and Web Development; Hi all I wonder if anyone on here can help me? I have built an Application in VB2008 Express that ...
  1. #1

    Join Date
    Feb 2009
    Posts
    2
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Saving Text in VB2008 as Picture File?

    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
    Last edited by ChrisVB2008; 9th February 2009 at 03:59 PM.

  2. #2

    Join Date
    Feb 2009
    Posts
    45
    Thank Post
    1
    Thanked 5 Times in 5 Posts
    Rep Power
    12
    Quote Originally Posted by ChrisVB2008 View Post
    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


  3. #3

    Join Date
    Feb 2009
    Posts
    2
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    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
    Last edited by ChrisVB2008; 16th February 2009 at 10:28 AM.

  4. #4

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,241
    Thank Post
    882
    Thanked 2,743 Times in 2,317 Posts
    Blog Entries
    11
    Rep Power
    784
    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

SHARE:
+ Post New Thread

Similar Threads

  1. PHP to text file
    By Hightower in forum Web Development
    Replies: 21
    Last Post: 24th October 2008, 09:52 AM
  2. Sysprep config – delete a text file
    By FN-GM in forum Windows
    Replies: 12
    Last Post: 16th September 2008, 12:57 PM
  3. [MS Office - XP] Word file saving
    By cantthinkofanickname in forum Office Software
    Replies: 0
    Last Post: 10th September 2008, 02:48 PM
  4. Batch: Text file -> Environment variable?
    By PiqueABoo in forum Scripts
    Replies: 5
    Last Post: 13th December 2006, 11:09 PM
  5. URLblacklist.com as text file
    By adamyoung in forum How do you do....it?
    Replies: 11
    Last Post: 9th February 2006, 02:35 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •