Do you recommend a converter?Quote:
All images from NSipData.NOS of KR client converted to PNG ^-^
[Only registered and activated users can see links. Click Here To Register...]
?Quote:
Do you recommend a converter?
Module NConverter
Sub Main()
If Not IO.Directory.Exists("ip") Then IO.Directory.CreateDirectory("ip")
For Each file As String In IO.Directory.GetFiles("ip")
Convert_To_PNG(file)
IO.File.Delete(file)
Next
End Sub
Function GetColor(ByVal byt As Byte, Optional ByVal encoding As Boolean = False) As Byte
If encoding Then
Return byt / &H11
Else
Return byt * &H11
End If
End Function
Function RGB4A_to_RGB888(ByVal clr As UInt16) As Drawing.Color
Dim A = (clr >> 12) And &HF
Dim R = (clr >> 8) And &HF
Dim G = (clr >> 4) And &HF
Dim B = clr And &HF
Return Drawing.Color.FromArgb(GetColor(A), GetColor(R), GetColor(G), GetColor(B))
End Function
Sub Convert_To_PNG(ByVal file_name As String)
Dim bReader As New IO.BinaryReader(IO.File.Open(file_name, IO.FileMode.Open))
Dim sprite_amount As Byte = bReader.ReadByte
Dim sprite_width As UInt16 = bReader.ReadUInt16
Dim sprite_height As UInt16 = bReader.ReadUInt16
Dim sprite_unknow As UInt32 = bReader.ReadUInt32
Dim sprite_offset As UInt32 = bReader.ReadUInt32
Console.WriteLine("Parsing file {0}, has {1} sprites ({2} x {3})", file_name, sprite_amount, sprite_width, sprite_height)
bReader.BaseStream.Seek(sprite_offset, IO.SeekOrigin.Begin)
Dim bmp As New Drawing.Bitmap(sprite_width, sprite_height)
For y = 0 To sprite_height - 1 Step 1
For x = 0 To sprite_width - 1 Step 1
bmp.SetPixel(x, y, RGB4A_to_RGB888(bReader.ReadUInt16))
Next
Next
bmp.Save(file_name & ".png", Drawing.Imaging.ImageFormat.Png)
bmp.Dispose()
bReader.Close()
bReader.Dispose()
End Sub
End Module
Nice. You maybe know how to reverse this action? (png -> binary)Quote:
?
I wrotte a console app in vb.net to do the conversions, the code is this:
Code:Module NConverter Sub Main() If Not IO.Directory.Exists("ip") Then IO.Directory.CreateDirectory("ip") For Each file As String In IO.Directory.GetFiles("ip") Convert_To_PNG(file) IO.File.Delete(file) Next End Sub Function GetColor(ByVal byt As Byte, Optional ByVal encoding As Boolean = False) As Byte If encoding Then Return byt / &H11 Else Return byt * &H11 End If End Function Function RGB4A_to_RGB888(ByVal clr As UInt16) As Drawing.Color Dim A = (clr >> 12) And &HF Dim R = (clr >> 8) And &HF Dim G = (clr >> 4) And &HF Dim B = clr And &HF Return Drawing.Color.FromArgb(GetColor(A), GetColor(R), GetColor(G), GetColor(B)) End Function Sub Convert_To_PNG(ByVal file_name As String) Dim bReader As New IO.BinaryReader(IO.File.Open(file_name, IO.FileMode.Open)) Dim sprite_amount As Byte = bReader.ReadByte Dim sprite_width As UInt16 = bReader.ReadUInt16 Dim sprite_height As UInt16 = bReader.ReadUInt16 Dim sprite_unknow As UInt32 = bReader.ReadUInt32 Dim sprite_offset As UInt32 = bReader.ReadUInt32 Console.WriteLine("Parsing file {0}, has {1} sprites ({2} x {3})", file_name, sprite_amount, sprite_width, sprite_height) bReader.BaseStream.Seek(sprite_offset, IO.SeekOrigin.Begin) Dim bmp As New Drawing.Bitmap(sprite_width, sprite_height) For y = 0 To sprite_height - 1 Step 1 For x = 0 To sprite_width - 1 Step 1 bmp.SetPixel(x, y, RGB4A_to_RGB888(bReader.ReadUInt16)) Next Next bmp.Save(file_name & ".png", Drawing.Imaging.ImageFormat.Png) bmp.Dispose() bReader.Close() bReader.Dispose() End Sub End Module
Did you had a look at my [Only registered and activated users can see links. Click Here To Register...]? I think I keep having the code, I can send you If you wanna itQuote:
Nice. You maybe know how to reverse this action? (png -> binary)
I had a look to the png files a bit and I have to say it's very difficulty.