Convert String to Image

  • Thread starter Thread starter jcrouse
  • Start date Start date
J

jcrouse

Well, this is the last step (I hope). I use the following code to write a
background image path to an xml file:

Dim dr31 As DataRow = ds.Tables("MainForm").NewRow

dr31("Width") = Me.Width

dr31("Height") = Me.Height

Dim frmback As String = (OpenFileDialog2.FileName).ToString

dr31("Background") = frmback


Here is the xml file:

<MainForm>

<Width>640</Width>

<Height>458</Height>

<Background>C:\CPViewer\Background.jpg</Background>

</MainForm>

</CPViewer>







As per my other thread on color, how do I now read this in from the dataset
and convert the string to an image? Or maybe, how do I right it out
properly? Here is my read code:

Me.Width = ds.Tables(30).Rows(0).Item(0).ToString

Me.Height = ds.Tables(30).Rows(0).Item(1).ToString



'bmGlobal = ("C:\cpviewer\backgroung.jpg").ToString



Me.BackgroundImage = bmGlobal

End If

Me.CenterToScreen()


You can see, I've tried a few things but no luck as of yet.

Thanks,
John
 
Me.BackgroundImage = New Bitmap("C:\cpviewer\backgroung.jpg")
or Me.BackgroundImage = New Bitmap(bmGlobal) if you assigned your
image path to 'bmGlobal'.

hope this helps..
 
Hi John,

If you want it I have made a sample to write the bitmap to the XML file,
however your XML file becomes that a little bit larger.

Cor
 
* "jcrouse said:
Dim frmback As String = (OpenFileDialog2.FileName).ToString

Just FYI: 'OpenFileDialog2.FileName' is already a string, so you don't
need to call 'ToString'.
 
Back
Top