Imports System.IO ' Created by Zachery Johnson ' email - jzach.hte@gmail.com ' Version 1.0 'This will grab the rgb value for ever pixel in an image and save it to a comma delimited text file. 'Once the text file is done, you may import this into a spread sheet application, such as Excel or Origin. 'This program will work on ny size image, however large images may result in data sizes exceeding 80 million values 'and may become unworkable. ' Beckman Institute ' Imaging Technology Group ' University of Illinois at Urbana-Champaign ' 405 N. Mathews, Urbana, IL 61801 ' itg@itg.uiuc.edu ' Copyright 2009, Board of Trustees of the University of Illinois, ' All Rights Reserved ' This is unpublished proprietary software developed by the Beckman ' Institute Imaging Technology Group (ITG) at the University of ' Illinois at Urbana-Champaign (UIUC). The copyright notice above does not ' evidence any actual or intended publication of such software. ' This software may not be redistributed for any purpose and may not ' be used for or incorporated in commercial products or services without ' the prior written permission of UIUC c/o The Beckman Institute Imaging ' Technology Group. ' All advertising materials mentioning features or use of this software ' must display the following acknowledgement: This product includes software ' developed by The Beckman Institute Imaging Technology Group at the ' University of Illinois at Urbana-Champaign. ' UIUC MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE ' FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED ' WARRANTY. THE UI SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE ' USERS OF THIS SOFTWARE. Public Class form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles getBtn.Click Dim xLoop As Integer = 0 Dim zLoop As Integer = 0 Dim pixelCMax As Integer Dim instance As MTAThreadAttribute Dim fileSize As Long = -1 On Error Resume Next fileSize = FileLen(imageTxt.Text) If fileSize = -1 Then MsgBox("The image you entered does not exist") ElseIf saveTxt.Text = "" Then MsgBox("Please select a location to save the file to.") Else MsgBox("Warning: Large images may take time. This will ask you to save and say done when finished.") Dim myImage As New Bitmap(imageTxt.Text) Dim imageWidth As Integer = myImage.Width Dim imageHeight As Integer = myImage.Height Dim totalPixels As Integer = (imageWidth * imageHeight) Dim progBarValue As Integer Dim pixelColor As Color Dim pixelCounter As Integer = 0 Dim writer As StreamWriter = New StreamWriter(saveTxt.Text) Do While zLoop < (imageWidth) Do While xLoop < (imageHeight) progBarValue = ((pixelCounter / totalPixels) * 100) progBar.Value = progBarValue percentTxt.Text = (progBarValue.ToString + "%") pixelColor = myImage.GetPixel(xLoop, zLoop) Dim pixelString = pixelColor.ToString Dim stringLength = Len(pixelString) stringLength = (stringLength - 1) pixelString = Mid$(pixelString, 8, (stringLength)) stringLength = (Len(pixelString) - 1) pixelString = Mid$(pixelString, 1, (stringLength)) pixelString = Mid$(pixelString, 1, 2) + "," + Mid$(pixelString, 3, stringLength) 'adds comma for Alpha Dim rEqual = InStr(pixelString, "R=") ' adds comma after r value stringLength = Len(pixelString) pixelString = Mid$(pixelString, 1, (rEqual + 1)) + "," + Mid$(pixelString, (rEqual + 2), stringLength) Dim gEqual = InStr(pixelString, "G=") ' adds comma after g value stringLength = Len(pixelString) pixelString = Mid$(pixelString, 1, (gEqual + 1)) + "," + Mid$(pixelString, (gEqual + 2), stringLength) Dim bEqual = InStr(pixelString, "B=") ' adds comma after b value stringLength = Len(pixelString) pixelString = Mid$(pixelString, 1, (bEqual + 1)) + "," + Mid$(pixelString, (bEqual + 2), stringLength) pixelCounter += 1 pixelCMax = pixelCounter xLoop += 1 writer.WriteLine(pixelString.ToString) Application.DoEvents() Loop xLoop = 0 zLoop += 1 Loop writer.Close() MsgBox("Done") End If End Sub Private Sub browseBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles imageBrowseBtn.Click openFD.InitialDirectory = "C:\" openFD.FileName = "" openFD.Title = "Choose an Image to Get Values From." openFD.Filter = "Jpeg|*.jpg|Tiff|*.TIFF|Targa|*.TGA|PNG|*.PNG|BMP|*.BMP|All files (*.*)|*.*""" openFD.ShowDialog() Dim strImage As String = openFD.FileName imageTxt.Text = strImage End Sub Private Sub saveBrowseBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles saveBrowseBtn.Click Dim saveFileDialog1 As New SaveFileDialog() saveFD.InitialDirectory = "C:\" saveFD.Title = "Save File As." saveFD.Filter = "Text|*.txt|All files (*.*)|*.*" saveFD.OverwritePrompt = True If saveFD.ShowDialog() = DialogResult.OK Then Else End If saveTxt.Text = saveFD.FileName End Sub End Class