I agree. At this time I probably will concentrate on other features.
Yes, certainly. Along with the other ships on the track. I actually started to code it earlier, but had problems with the 3d object model, which was unaligned with the road 3d model (or 2.5d if you like). I am coming back to it after a while. However I already made a fast scaler for the billboard bitmaps and ships.
I’m not sure about the colour combination of the diamond pattern.
I threw together my own palette extractor while I was at it, and it generated this:
I had to do some trickery to get the colours in the order I wanted though.
(I’ll have to think of a clever way to group/sort them so that they group together in a logical order by default.)
Since you mentioned the sea, here’s a peek at my failed attempts next to the final version of the sea tile:
How does it work? Generating the palette for 256 color image which contains all the graphics is one of the manual phases I have to do with Gimp. NetPmb needs the palette as a 256x1 pixel image, so I have to do it manually as well.
Applying the new palette to all old textures and making a C code of them is done by a script.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace PaletteSpitter
{
class Program
{
static void Main(string[] args)
{
List<Color> set = new List<Color>();
foreach (var file in args)
using (var bitmap = new Bitmap(file))
for (int y = 0; y < bitmap.Height; ++y)
for (int x = 0; x < bitmap.Width; ++x)
{
var colour = bitmap.GetPixel(x, y);
if (!set.Contains(colour) && colour.A == byte.MaxValue)
set.Add(colour);
}
if (set.Count > 0)
using (var result = new Bitmap(set.Count * 8, 8))
{
using (var graphics = Graphics.FromImage(result))
foreach (var pair in set.Zip(Enumerable.Range(0, set.Count), Tuple.Create))
using (var brush = new SolidBrush(pair.Item1))
graphics.FillRectangle(brush, new Rectangle(pair.Item2 * 8, 0, 8, 8));
result.Save("palette.png");
}
}
}
}
It’s not very sophisticated, I threw it together in 5 minutes and spent 25 playing around with it to try to get it to sort the colours in a sensible way (and then gave up on that).
I could rewrite it to generate a 256x1 image easily enough.
Given time I could write something more sophisticated.
Perfect! I think I can use it almost as such. The only changes needed are that the resulting image size is set.Count x 1 pixels, and that the first color is pink (255,9,255), which I use as a transparent color.
With an image that’s only 1 pixel tall, the ‘graphics’ and ‘brush’ stuff can be skipped and SetPixel can be used instead:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace PaletteSpitter
{
class Program
{
static void Main(string[] args)
{
List<Color> set = new List<Color>();
foreach (var file in args)
using (var bitmap = new Bitmap(file))
for (int y = 0; y < bitmap.Height; ++y)
for (int x = 0; x < bitmap.Width; ++x)
{
var colour = bitmap.GetPixel(x, y);
if (!set.Contains(colour) && colour.A == byte.MaxValue)
set.Add(colour);
}
if (set.Count > 0)
using (var result = new Bitmap(set.Count, 1))
{
foreach (var pair in set.Zip(Enumerable.Range(0, set.Count), Tuple.Create))
result.SetPixel(pair.Item2, 0, pair.Item1);
result.Save("palette.png");
}
}
}
}
(Maybe worth mentioning: powershell can use .net stuff, so this can be turned into a powershell script as well.)
This compiler is provided as part of the Microsoft ® .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240
genpalette.cs(1,1): error CS0116: A namespace cannot directly contain members such as fields or methods
genpalette.cs(28,1): error CS1022: Type or namespace definition, or end-of-file expected
By the way, I was originally using a SortedSet which is why the list is called set.
I should really change it to colours or palette, but like I say, I threw it together in a few minutes.
C# is one of my favourite languages for writing ‘throwaway’ programs because it’s easy to write useful things quickly.