Image to String, String to Image
*
Option Strict On
Public Class Form1

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.Title = "대상 파일"
OpenFileDialog1.FileName = ""
OpenFileDialog1.ShowDialog()
PictureBox1.ImageLocation = OpenFileDialog1.FileName
End Sub

Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
BackgroundWorker1.RunWorkerAsync()
End Sub


Private Sub BackgroundWorker1_DoWork(sender As System.Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
CheckForIllegalCrossThreadCalls = False

Dim Bild As Bitmap = CType(Me.PictureBox1.Image.Clone, Bitmap)
Dim width As Integer = Bild.Width - 1
Dim height As Integer = Bild.Height - 1
For x = 1 To width
For y = 1 To height
ProgressBar1.Maximum = width * height
BackgroundWorker1.ReportProgress(x * y)
Dim R, G, B, A As Integer
R = Bild.GetPixel(x, y).R
G = Bild.GetPixel(x, y).G
B = Bild.GetPixel(x, y).B
A = Bild.GetPixel(x, y).A

RichTextBox1.AppendText(R & "-" & G & "-" & B & "-" & A & "-" & x & "," & y & vbNewLine)
Next
Next

RichTextBox1.Text = RichTextBox1.Text.Substring(0, RichTextBox1.Text.Length - 1)
RichTextBox1.AppendText("|" & width & "*" & height)
End Sub

Private Sub BackgroundWorker1_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
ProgressBar1.Value = e.ProgressPercentage
End Sub
End Class

이 게시물을

공유하기

SEARCH

MENU NAVIGATION