The patch worked like a charm. I guess it's true about arrays being evil :)
Thanks, Jesse Z. <quote who="Glenn Wurster"> > I have attached a patch below which may fix the problem. Index is a > WORD but yet we only have 256 entries in the palette that we get from > GetPaletteEntries - if any of the values is more, we jump past the end > of pal_ents. I've modified the function to allow access to all 65536 > colour values and adjust for values that are beyond the range of valid > palette indexes. The patch is completely untested but let me know if > it fixes the issue.