在PNG文件格式wikipedia page中,我看到图像转换为每像素位成本的表示(红色=昂贵,蓝色=便宜)。
我想知道编程那种转换器是否可行。
目前我还不知道在哪里查找有关这方面的信息,所以我决定在这里询问我所做的小VB.NET代码:
Dim MyBitmap As Bitmap = New Bitmap(filename:="C:\Original.png")
Dim MyBinaryReader As BinaryReader = New BinaryReader(File.OpenRead(path:="C:\Original.png"))
Dim MyBytes() As Byte = MyBinaryReader.ReadBytes(count:=Convert.ToInt32(File.OpenRead(path:="C:\Original.png").Length))
Dim MyString As String = ""
For Each MyByte As Byte In MyBytes
MyString = MyString & Convert.ToString(value:=MyByte, toBase:=2).PadLeft(totalWidth:=8, paddingChar:="0"c)
Next
Debug.WriteLine(MyString)
'For MyHeight As Integer = 0 To MyBitmap.Height - 1
' For MyHeight As Integer = 0 To MyBitmap.Height - 1
' MyBitmap.SetPixel(x:=MyWidth, y:=MyHeight, color:=MyBitmap.GetPixel(x:=MyWidth, y:=MyHeight))
' Next
'Next
'MyBitmap.Save(filename:="C:\New.png")