Public Function SetImageComment(input As Image, comment As String) As Image Using memStream As
New IO.MemoryStream()
input.Save(memStream, Imaging.ImageFormat.Jpeg)
memStream.Position = 0 Dim decoder As New JpegBitmapDecoder(memStream, BitmapCreateOptions.PreservePixelFormat,
BitmapCacheOption.OnLoad) Dim metadata As BitmapMetadata If decoder.Metadata Is Nothing Then metadata =New BitmapMetadata("jpg") Else metadata =decoder.Metadata End If
metadata.Comment = comment Dim bitmapFrame = decoder.Frames(0) Dim encoder As BitmapEncoder = New JpegBitmapEncoder()
encoder.Frames.Add(bitmapFrame.Create(bitmapFrame,bitmapFrame.Thumbnail, metadata, bitmapFrame.ColorContexts)) Dim imageStream As New IO.MemoryStream
encoder.Save(imageStream)
imageStream.Position = 0
input.Dispose() input =Nothing Return Image.FromStream(imageStream) End Using End Function
I developed a code to display my text in a picturebox using drawstring method.. i have saved that picturebox to an bmp file.. Now i have to convert that bmp file to an .txt file or byte() .. i dono how to convert it.. Can u help me in solving this problem..
thank u in advance..
my code is..
Public Class Form1 Dim brush As New Drawing.SolidBrush(Color.Black) Dim g2 As System.Drawing.Graphics Dim img As New Bitmap(400, 100)
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
g2 = Graphics.FromImage(img) PictureBox1.Image = img g2.SmoothingMode = Drawing2D.SmoothingMode.HighQuality g2.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit g2.CompositingQuality = Drawing2D.CompositingQuality.HighQuality ' g2.DrawString(TextBox1.Text, TextBox1.Font, Brushes.Red, 0, 0) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click SaveFileDialog1.FileName = "" If SaveFileDialog1.ShowDialog <> 1 Then Exit Sub Try Select Case SaveFileDialog1.FilterIndex Case 1 img.Save(SaveFileDialog1.FileName, ImageFormat.Bmp) Case 2 End Select Catch MsgBox("Can not save the LED image!", 48, "LED Saving") End Try End Sub End Class
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Can you answer this question?
Write Answer3 Answers