Private Declare Function GetPixel Lib "gdi32" _
(ByVal hdc As Long, ByVal x As Long, _ ByVal y As Long) As Long Private Sub Form_Load() Me.Top = 0 Me.Left = 0 Picture1.ScaleMode = 3 Picture1.Top = 0 Picture1.Left = 0 Picture1.AutoSize = True Picture1.Picture = LoadPicture("c:\windows\desktop\" & _ InputBox("Picture da convertire c:\windows\desktop\", _ "Pic2txt")) Me.Width = Picture1.Width + 120 Me.Height = Picture1.Height + 405 Me.Show Dim x As Integer Dim y As Integer Dim tempcolor As Long Open "c:\windows\desktop\picture.txt" For Output As #1 For y = 1 To Picture1.ScaleHeight Step 2 For x = 1 To Picture1.ScaleWidth - 1 tempcolor = GetPixel(Picture1.hdc, x, y) Print #1, Mid("#iex+..", Int((Int(tempcolor / 65536) + _ Int((tempcolor - Int(tempcolor / 65536) * 65536) / 256) + _ tempcolor - Int(tempcolor / 256) * 256) / 3 / 42.5) + 1, 1); Next x Picture1.PSet (2, y), vbRed Print #1, "" Next y Close #1 MsgBox "Cicture convertita su: C:\WINDOWS\DESKTOP\PICTURE.TXT", _ End Sub |