Item Icon Import Enhancement

Made it so the item icon importer will automtically lower the number of colors in a picture to 16. Also potentially fixed an issue where part of the pokemon edit window would be cut off on devices with dpi scaling at above 100%.
This commit is contained in:
Dreuu 2018-09-18 21:21:05 -04:00
parent 3874941cef
commit f692474faa
20 changed files with 165 additions and 23 deletions

Binary file not shown.

View File

@ -467,4 +467,17 @@ Module ExportDataFunctions
End Sub
Public Sub ExportItemPicture(DataPath As String, ItemIndex As Integer, Optional Individual As Boolean = False)
Dim ItemPicDataOff As Integer = Int32.Parse(GetString(GetINIFileLocation(), header, "ItemIMGData", ""), System.Globalization.NumberStyles.HexNumber)
Dim ItemPalDataOff As Integer = Int32.Parse(GetString(GetINIFileLocation(), header, "ItemIMGData", ""), System.Globalization.NumberStyles.HexNumber)
Dim ItemPicDataOffSpecific As String = Hex(Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ItemPicDataOff + (ItemIndex * 8), 4))), System.Globalization.NumberStyles.HexNumber) - &H8000000)
Dim ItemPalDataOffSpecific As String = Hex(Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ItemPalDataOff + (ItemIndex * 8) + 4, 4))), System.Globalization.NumberStyles.HexNumber) - &H8000000)
Dim bitout As Bitmap = GetAndDrawItemIconToBitmap(ItemPicDataOffSpecific, ItemPalDataOffSpecific, True)
bitout.Save(DataPath)
End Sub
End Module

View File

@ -1027,19 +1027,6 @@ Module ImportDataFunctions
WriteString(DataPath, "Item", "ItemName", ItemName)
End Sub
Public Sub ExportItemPicture(DataPath As String, ItemIndex As Integer, Optional Individual As Boolean = False)
Dim ItemPicDataOff As Integer = Int32.Parse(GetString(GetINIFileLocation(), header, "ItemIMGData", ""), System.Globalization.NumberStyles.HexNumber)
Dim ItemPalDataOff As Integer = Int32.Parse(GetString(GetINIFileLocation(), header, "ItemIMGData", ""), System.Globalization.NumberStyles.HexNumber)
Dim ItemPicDataOffSpecific As String = Hex(Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ItemPicDataOff + (ItemIndex * 8), 4))), System.Globalization.NumberStyles.HexNumber) - &H8000000)
Dim ItemPalDataOffSpecific As String = Hex(Int32.Parse((ReverseHEX(ReadHEX(LoadedROM, ItemPalDataOff + (ItemIndex * 8) + 4, 4))), System.Globalization.NumberStyles.HexNumber) - &H8000000)
Dim bitout As Bitmap = GetAndDrawItemIconToBitmap(ItemPicDataOffSpecific, ItemPalDataOffSpecific, True)
bitout.Save(DataPath)
End Sub
Public Sub ImportItem(DataPath As String, ItemIndex As Integer, Optional Individual As Boolean = False)
Dim iniPath As String = ""
@ -1131,7 +1118,7 @@ Module ImportDataFunctions
End Sub
Public Sub ImportItemPicture(pngpath As String, ItemIndex As String, Optional Individual As Boolean = False)
Dim ItemPalette As Color() = New Color(&H11 - 1) {}
'Dim ItemPalette As Color() = New Color(&H11 - 1) {}
Dim mainbitmap As New Bitmap(pngpath)
Dim ItemBitmap As Bitmap = New Bitmap(&H18, &H18)
Dim ItemPicDataOff As Integer = Int32.Parse(GetString(GetINIFileLocation(), header, "ItemIMGData", ""), System.Globalization.NumberStyles.HexNumber)
@ -1144,9 +1131,29 @@ Module ImportDataFunctions
End If
BitmapBLT(mainbitmap, ItemBitmap, 0, 0, 0, 0, &H18, &H18, Color.FromArgb(&HFF, 200, 200, &HA8))
ItemPalette = GetBitmapPalette(ItemBitmap)
Dim ItemPalette As Color() = GetBitmapPaletteNoLimit(ItemBitmap)
' ConvertBitmapToPalette(ItemBitmap, ItemPalette, True)
While ItemPalette.Count() > 16
Dim BufferPal As New List(Of Color)
For looper = 1 To ItemPalette.Count() - 1
BufferPal.Add(ItemPalette(looper))
Next
BufferPal = RemoveOneColor(BufferPal)
BufferPal.InsertRange(0, {ItemPalette(0)})
ItemPalette = BufferPal.ToArray()
End While
ConvertBitmapToPalette(ItemBitmap, ItemPalette, True)
While ItemPalette.Count < 16
Dim BufferList As List(Of Color) = ItemPalette.ToList()
BufferList.Add(Color.FromArgb(&HFFFFFF))
ItemPalette = BufferList.ToArray()
End While
Dim Sprite As Byte() = SaveBitmapToArray(ItemBitmap, ItemPalette)
@ -1216,6 +1223,57 @@ Module ImportDataFunctions
End Sub
Public Function RemoveOneColor(pal As List(Of Color)) As List(Of Color)
RemoveOneColor = New List(Of Color)
Dim colorDiffs As List(Of List(Of Integer)) = New List(Of List(Of Integer))
Dim looper As Integer = 0
For col = 0 To pal.Count() - 1
Dim innerloop As Integer = 0
colorDiffs.Add(New List(Of Integer))
For innerCol = 0 To pal.Count() - 1
Dim testColDiff As Integer = 99999
If innerCol > col Then
If Not col = innerCol Then
testColDiff = GetColorDifference(pal(col), pal(innerCol))
End If
End If
colorDiffs(looper).Add(testColDiff)
innerloop += 1
Next
looper += 1
Next
looper = 0
Dim oldDiff As Integer = 99999
Dim colorsToCombine As Integer() = {0, 0}
For Each diffList As List(Of Integer) In colorDiffs
Dim innerloop As Integer = 0
For Each diff As Integer In diffList
If diff < oldDiff Then
oldDiff = diff
colorsToCombine = {looper, innerloop}
End If
innerloop += 1
Next
looper += 1
Next
pal.RemoveAt(colorsToCombine(1))
RemoveOneColor = pal
Return RemoveOneColor
End Function
Public Function GetLongString(ByVal strFilename As String, ByVal Section As String,
ByVal Key As String, ByVal [Default] As String) As String

View File

@ -3164,6 +3164,8 @@ Partial Class Pokemonedit
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(9.0!, 20.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.AutoSize = True
Me.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink
Me.ClientSize = New System.Drawing.Size(1173, 862)
Me.Controls.Add(Me.CheckBox1)
Me.Controls.Add(Me.Button41)

View File

@ -178,6 +178,35 @@ Module WichuSpriteFunctions
Return source
End Function
Public Function GetBitmapPaletteNoLimit(ByRef sprite As Bitmap) As Color()
Dim source As List(Of Color) = New List(Of Color)
Dim output As Color()
Dim index As Byte = 0
Dim num4 As Integer = (sprite.Width - 1)
Dim i As Integer = 0
Do While (i <= num4)
Dim num5 As Integer = (sprite.Height - 1)
Dim j As Integer = 0
Do While (j <= num5)
Dim pixel As Color = sprite.GetPixel(i, j)
If Not Enumerable.Contains(Of Color)(source, pixel) Then
source.Add(pixel)
Try
index = CByte((index + 1))
Catch
output = source.ToArray()
Return output
End Try
End If
j += 1
Loop
i += 1
Loop
output = source.ToArray()
Return output
End Function
Public Function GetBottom(ByRef bitmap As Bitmap) As Integer
Dim num As Integer
Dim height As Integer = bitmap.Height

View File

@ -16,7 +16,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>STP1VDfTNIHfZwlMIZtEcP/4dC+tiPQmRKAFU7jZsWs=</dsig:DigestValue>
<dsig:DigestValue>JZ/yNR9sYljS/IhYA4Ww/XxO8tNvKsGCVsFKp+fcc7s=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>

View File

@ -43,14 +43,14 @@
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="PokemonGameEditor.exe" size="2115072">
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="PokemonGameEditor.exe" size="2116608">
<assemblyIdentity name="PokemonGameEditor" version="3.8.1.0" language="neutral" processorArchitecture="msil" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>7/d6GKNeUDnSkylkNXBrpTWlT/c/Ia0xRygIhk/hyck=</dsig:DigestValue>
<dsig:DigestValue>/LAGoYEv+gEfNNZtPg7UNZdlsVRXqCe03eNP6vNItTk=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>

View File

@ -1 +1 @@
ef0dc9cc3316fe1b4494e557fc7828a03aa4043f
3c28dccb3590a299f877aecd8a64b5acf689d462

View File

@ -262,3 +262,43 @@ C:\Users\Drew\Desktop\Github\NewPokemonGameEditor\PokemonGameEditor\GBAPokemonGa
C:\Users\Drew\Desktop\Github\NewPokemonGameEditor\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.TrustInfo.xml
C:\Users\Drew\Desktop\Github\NewPokemonGameEditor\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.exe.manifest
C:\Users\Drew\Desktop\Github\NewPokemonGameEditor\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.application
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\bin\Debug\PokemonGameEditor.exe.config
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\bin\Debug\PokemonGameEditor.exe.manifest
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\bin\Debug\PokemonGameEditor.application
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\bin\Debug\PokemonGameEditor.exe
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\bin\Debug\PokemonGameEditor.pdb
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\bin\Debug\PokemonGameEditor.xml
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\GBAPokemonGameEditor.vbprojAssemblyReference.cache
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.AbilityAdder.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.AbilityEdit.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.AboutBox1.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.AddOrRemovePrograms.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.AttackEditor.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.AttackAdder.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.BattleFrontierEditor.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.EggMoveEditor.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.HabitatEditor.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.InputAttacks.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.ItemEditor.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.MainFrm.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.movetutor2.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.Resources.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.PokedexDataEditor.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.PokedexListEditor.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.PokedexOrderEditor.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.PokemonAdder.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.Pokemonedit.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.RomExpander.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.RSEStarterEditor.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.SplashScreen1.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.TMHMEditor.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.TradeEditor.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.TrainerEditor.resources
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\GBAPokemonGameEditor.vbproj.GenerateResource.cache
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\GBAPokemonGameEditor.vbproj.CoreCompileInputs.cache
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.TrustInfo.xml
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.exe.manifest
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.application
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.exe
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.xml
C:\Users\manma\Documents\PokeDev\PGE-Github\PokemonGameEditor\GBAPokemonGameEditor\obj\x86\Debug\PokemonGameEditor.pdb

View File

@ -16,7 +16,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>STP1VDfTNIHfZwlMIZtEcP/4dC+tiPQmRKAFU7jZsWs=</dsig:DigestValue>
<dsig:DigestValue>JZ/yNR9sYljS/IhYA4Ww/XxO8tNvKsGCVsFKp+fcc7s=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>

View File

@ -43,14 +43,14 @@
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="PokemonGameEditor.exe" size="2115072">
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="PokemonGameEditor.exe" size="2116608">
<assemblyIdentity name="PokemonGameEditor" version="3.8.1.0" language="neutral" processorArchitecture="msil" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>7/d6GKNeUDnSkylkNXBrpTWlT/c/Ia0xRygIhk/hyck=</dsig:DigestValue>
<dsig:DigestValue>/LAGoYEv+gEfNNZtPg7UNZdlsVRXqCe03eNP6vNItTk=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>