|
-
Jul 12th, 2008, 06:59 PM
#14
Thread Starter
Fanatic Member
Re: save JPG into file
I am trying to save the text with the images. I can not get the bytes. I tried convert, but that did not work either. Anyways, if you could help me write the text before and after the image, and also if you could help me read it in nicely, I would really appreciate it. I know this should not be that hard, but I am having trouble figuring out a good way to do this.
Error 18 Value of type 'String' cannot be converted to '1-dimensional array of Byte'. C:\Reports\Jeff\VB\study\StudyX.NET\frmPictureViewer.vb 117 18 studyX
Code:
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
'Dim testImage As Image
'Image.FromHbitmap()
' Sets up an image object to be displayed.
If Not (myImage Is Nothing) Then
myImage.Dispose()
End If
' Stretches the image to fit the pictureBox.
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
myImage = New Bitmap("c:\resume.jpg")
PictureBox1.ClientSize = New Size(100, 100)
PictureBox1.Image = CType(myImage, Image)
'Dim myStream As StreamWriter
'myStream = New StreamWriter("c:\theImageTest.jpg") 'SaveFileDialog1.FileName)
'If Not (myStream Is Nothing) Then
' PictureBox1.Image.Save(myStream, System.Drawing.Imaging.ImageFormat.Jpeg)
' 'myStream.WriteLine(123)
'End If
'Create a new instance of the FileStream class
Dim fs As New IO.FileStream("c:\NewImage.jpg", IO.FileMode.Create, IO.FileAccess.Write, IO.FileShare.None)
'Pass the FileStream instance to the picturebox' Save method
fs.Write("<Image1start>", 0, 1000)
PictureBox1.Image.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg)
fs.Write("<Image1end>", 0, 1000)
fs.Write("<Image2start>", 0, 1000)
PictureBox1.Image.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg)
fs.Write("<Image2end>", 0, 1000)
'Close and dispose the FileStream object once we're done with it.
fs.Close()
'fs.Dispose()
'PictureBox1.Image.FromFile("c:\StudyX.bmp")
'PictureBox1.Update()
'PictureBox1.Refresh()
'Dim bmp As Bitmap = CType(Me.PictureBox1.Image, Bitmap)
'MessageBox.Show("Before setting the pixel {5,5} to white color " & bmp.GetPixel(5, 5).ToString)
'bmp.SetPixel(5, 5, Color.White)
'Me.PictureBox1.Image = bmp
'MessageBox.Show("After setting the pixel {5,5} to white color " & bmp.GetPixel(5, 5).ToString)
End Sub
I use VB .NET 2022. Currently developing StudyX educational software, PlazSales POS system and Yargis a space ship shooter game.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|