Sunday, January 17, 2016

FMod - Fixing Graphics Re-import

In writing the NetKeen Tile Migration Tool, I took advantage of the semi-new NextGenGraphics class in FleexCore2. While testing the part where it copies the tiles, I ran into some problems - the tiles were corrupted after being written back to disk. I discovered three problems:

  • An incorrect variable was used in place of a similarly-named variable, causing ColorsToBinary to look at the wrong indexes in the colors array (or crash, in some cases).
  • The actual color part of the color ID in BitmapToColors was shifted left too far, causing the mask to be treated as the actual color in ColorsToBinary.
  • Thanks to some incorrect bit twiddling, the order of the color planes got reversed in ColorsToBinary.
I hadn't found these issues earlier because I had never tested modifying images before resaving the graphics resources. (Just opening and resaving doesn't fully deserialize and reserialize everything, only the modified parts.)

No comments:

Post a Comment