Palette Editor Download
Community Forums/Showcase/Palette Editor Download
| ||
OK. Here it is. the download for both macOS and Windows https://adamstrange.itch.io/paletteeditor ![]() Let me know how you get on with it. any problems, etc ;) I'll up the internal file format specs later |
| ||
Here is the load and save code in monkey2method LoadPalette( path:string ) Local file := Stream.Open( path, "r" ) If Not file Then Return Local header:string = file.ReadCString() If header = "mx2palette" Then Local count:int = file.ReadUInt() If count < 256 Then Local gridX:int = file.ReadUInt() If gridX < 8 Then Local gridY:int = file.ReadUInt() If gridY < 8 Then Local k:int Local red:float Local green:float Local blue:float Local alpha:float _gridCount = count GridX = gridX GridY = gridY For k = 0 Until count red = file.ReadFloat() green = file.ReadFloat() blue = file.ReadFloat() alpha = file.ReadFloat() _color[ k ] = New Color( red, green, blue, alpha ) Next End If End If End If End If file.Close() RequestRender() End method and here is the saving code method SavePalette( path:string ) Local file := Stream.Open( path, "w" ) If Not file Then Return Local header:string = "mx2palette" file.WriteCString( header ) file.WriteUInt( _gridCount ) file.WriteUInt( _gridX ) file.WriteUInt( _gridY ) Local k:int Local col:uint For k = 0 until _gridCount file.WriteFloat( _color[ k ].R ) file.WriteFloat( _color[ k ].G ) file.WriteFloat( _color[ k ].B ) file.WriteFloat( _color[ k ].A ) Next file.Close() End method so the file format is: string = "mx2palette" uint = gridcount (0..255) uint = gridx (1..16) uint = gridy (1..16) data block of gridcount float = red (0..1) float = green (0..1) float = blue (0..1) float = alpha (0..1) the colors are stored as float as this is the default format for monkey2 To convert to/from blitxmax, etc which is 0..255, just multiply (or divide) by 255 |
| ||
Dunno how mx formats floats... But in Blitzmax it uses locales (1,2 instead of 1.2 on German systems) To avoid that I first converted the float to string...and then replace commas with dots. Bye Ron |