画像色データ取出しツール
Return

■画像をピクセル単位に色を読み取ってテキストファイルに落とすプログラムです。
 APIを使用しているので簡単にJavaには書き換えられないでしょう(T-T)。
 ソースのみ公開します。エラー処理もないシンプルさが特徴です(^^;

実行画面のイメージ



■プログラムのソースは以下の通りです。VB5で動作しました。
'-------------------------------------------------------
' 画像の色情報をテキストファイルに保存する
' 2004.03.03 MARCO
'
'  [Picture1] [Text1] [Command1]
'         [Text2] [Command2]
' Picture1、Text1、Text2、Command1、Command2を配置する
'-------------------------------------------------------

Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long

Private Sub Command1_Click()
Picture1.Picture = LoadPicture(Text1.Text)
End Sub

Private Sub Command2_Click()
Dim A As Long
Dim SA As String

Open Text2.Text For Output As #1
For i = 0 To Picture1.ScaleWidth - 1
For j = 0 To Picture1.ScaleHeight - 1
A = GetPixel(Picture1.hdc, j, i)
SA = Hex(A)
If Len(SA) < 6 Then
Do Until Len(SA) = 6
SA = "0" & SA
Loop
End If
If j = Picture1.ScaleHeight - 1 Then
Print #1, Right(SA, 2) & Mid(SA, 3, 2) & Left(SA, 2)
Else
Print #1, Right(SA, 2) & Mid(SA, 3, 2) & Left(SA, 2) & ",";
End If
Next j
Next i
Close #1
MsgBox "complete"
End Sub

Private Sub Form_Load()
Picture1.ScaleMode = 3
Picture1.AutoSize = True
Command1.Caption = "load"
Command2.Caption = "save"
Text1.Text = "c:\temp\test.jpg" '画像ファイル名をフルパスで入力
Text2.Text = "c:\temp\test.txt" '保存するテキストファイル名
End Sub