aliens

Author Topic: replacing terrain graphics, bmp-->pck issue (Hobbes ?)  (Read 8193 times)

Offline robin

  • Commander
  • *****
  • Posts: 1214
  • ULTIMATE ROOKIE
    • View Profile
replacing terrain graphics, bmp-->pck issue (Hobbes ?)
« on: June 27, 2014, 02:36:10 pm »
I want to replace the graphics of some terrains (starting from the alien-related ones).

I'd liked to do this in a simple and quick way, so I:
1) convert the .pck into a .bmp (with pckview);
2) draw, then save as .bmp (with appropriate palette);
3) convert back to .pck with pckview (then overwriting the original pck files with my new ones).

But this is what happens, some tiles have "shifted" by 1 pixel horizontally.
This is strange because none of my modifications exceed the original tile width.



Is there a solution to this?
(attached the tileset below)

Offline Hobbes

  • Commander
  • *****
  • Posts: 2101
  • Infiltration subroutine in progress
    • View Profile
Re: replacing terrain graphics, bmp-->pck issue (Hobbes ?)
« Reply #1 on: June 27, 2014, 03:32:32 pm »
But this is what happens, some tiles have "shifted" by 1 pixel horizontally.

Does this 'shifting' appears when you are visualizing the PCK files on either PCKView or MCDEditor?

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: replacing terrain graphics, bmp-->pck issue (Hobbes ?)
« Reply #2 on: June 27, 2014, 03:32:59 pm »
try MCDEdit?

Offline robin

  • Commander
  • *****
  • Posts: 1214
  • ULTIMATE ROOKIE
    • View Profile
Re: replacing terrain graphics, bmp-->pck issue (Hobbes ?)
« Reply #3 on: June 27, 2014, 03:37:40 pm »
Does this 'shifting' appears when you are visualizing the PCK files on either PCKView or MCDEditor?
Yes. It happens during the conversion bmp-->pck, the bitmap is fine but the resulting pck is misplaced.

try MCDEdit?
I'll try it. (Link to the latest version?)

https://openxcom.org/forum/index.php?topic=1900.0 ?
https://openxcom.org/forum/index.php?topic=2028.30 ? this one  ?
« Last Edit: June 27, 2014, 03:48:23 pm by robin »

Offline Hobbes

  • Commander
  • *****
  • Posts: 2101
  • Infiltration subroutine in progress
    • View Profile
Re: replacing terrain graphics, bmp-->pck issue (Hobbes ?)
« Reply #4 on: June 27, 2014, 03:39:29 pm »
Yes. It happens during the conversion bmp-->pck, the bitmap is fine but the resulting pck is misplaced.
I'll try it.

Then usually the error is in the .bmp file. Usually there's a pixel that PCKView doesn't recognize the color value.

Offline robin

  • Commander
  • *****
  • Posts: 1214
  • ULTIMATE ROOKIE
    • View Profile
Re: replacing terrain graphics, bmp-->pck issue (Hobbes ?)
« Reply #5 on: June 27, 2014, 03:45:58 pm »
Then usually the error is in the .bmp file. Usually there's a pixel that PCKView doesn't recognize the color value.
How can that be though? The image is converted to use the appropriate palette, there's no "extra" or "wrong" color in  it.

Offline Hobbes

  • Commander
  • *****
  • Posts: 2101
  • Infiltration subroutine in progress
    • View Profile
Re: replacing terrain graphics, bmp-->pck issue (Hobbes ?)
« Reply #6 on: June 27, 2014, 03:50:01 pm »
How can that be though? The image is converted to use the appropriate palette, there's no "extra" or "wrong" color in  it.

I think I got it, check the attached file. On the left side of the image there's an image of one of my tiles and the palette it uses, on the right side there's your tileset and their palette. The first colors are different (they are marked in red).

Try this: open an original tile set, save as bmp one of its tiles. Afterwards open the bmp of your tile, copy the relevant part of the image and paste it over the bmp of the original tile, save it as bmp and load into into the PCK file and see if it gets properly displayed.
« Last Edit: June 27, 2014, 03:57:30 pm by Hobbes »

Offline robin

  • Commander
  • *****
  • Posts: 1214
  • ULTIMATE ROOKIE
    • View Profile
Re: replacing terrain graphics, bmp-->pck issue (Hobbes ?)
« Reply #7 on: June 27, 2014, 04:03:49 pm »
I think I got it, check the attached file. On the left side of the image there's an image of one of my tiles and the palette it uses, on the right side there's your tileset and their palette. The first colors are different (they are marked in red).

Try this: open an original tile set, save as bmp one of its tiles. Afterwards open the bmp of your tile, copy the relevant part of the image and paste it over the bmp of the original tile, save it as bmp and load into into the PCK file and see if it gets properly displayed.
Yeah the background color changes... it's like they don't use the same color for transparency....

I've downloaded the palettes form this forum (specifically here: https://openxcom.org/forum/index.php?topic=1557.msg16813#msg16813), and I've been using them since the beginning for all my sprites without issues.
Could be that the colors they use for transparency aren't compatible with pckview?


Offline Hobbes

  • Commander
  • *****
  • Posts: 2101
  • Infiltration subroutine in progress
    • View Profile
Re: replacing terrain graphics, bmp-->pck issue (Hobbes ?)
« Reply #8 on: June 27, 2014, 04:20:29 pm »
Yeah the background color changes... it's like they don't use the same color for transparency....

I've downloaded the palettes form this forum (specifically here: https://openxcom.org/forum/index.php?topic=1557.msg16813#msg16813), and I've been using them since the beginning for all my sprites without issues.
Could be that the colors they use for transparency aren't compatible with pckview?

I've used PCKView for years and it has always been very touchy regarding colors but at the same time, if it loads correctly at PCKView then it will be displayed properly on the original game.

I also got the palettes from that thread but I still simply design over a .bmp of an original image to use the original palette. Otherwise, chances are that one color will be wrongly translated.

Offline robin

  • Commander
  • *****
  • Posts: 1214
  • ULTIMATE ROOKIE
    • View Profile
Re: replacing terrain graphics, bmp-->pck issue (Hobbes ?)
« Reply #9 on: June 27, 2014, 05:48:44 pm »
What software is the one you're using (in that screen)? Photoshop is not being friendly and I need that PCView-compatible palette.

Offline Hobbes

  • Commander
  • *****
  • Posts: 2101
  • Infiltration subroutine in progress
    • View Profile
Re: replacing terrain graphics, bmp-->pck issue (Hobbes ?)
« Reply #10 on: June 27, 2014, 06:01:23 pm »
What software is the one you're using (in that screen)? Photoshop is not being friendly and I need that PCView-compatible palette.

GIMP but the program is getting that palette from the original image.

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2159
    • View Profile
Re: replacing terrain graphics, bmp-->pck issue (Hobbes ?)
« Reply #11 on: June 27, 2014, 09:56:11 pm »
Yeah the background color changes... it's like they don't use the same color for transparency....

I've downloaded the palettes form this forum (specifically here: https://openxcom.org/forum/index.php?topic=1557.msg16813#msg16813), and I've been using them since the beginning for all my sprites without issues.
Could be that the colors they use for transparency aren't compatible with pckview?
It's likely. For working with images, it's conventional to use "lime" or "pink" as the "transparent color" because it makes it easier to tell the background apart from the sprite.

In OpenXcom the color you use as the "transparent color" in your palette doesn't really matter because it uses "color 0" as the transparent color, not an RGB, so SDL will automatically figure it out when matching extraSprites with the original palettes/graphics.

However there's no guarantee that other programs will behave the same. If they are matching by RGB, you will have to change the first palette color to RGB 0,0,0.
« Last Edit: June 27, 2014, 10:01:55 pm by SupSuper »

Offline robin

  • Commander
  • *****
  • Posts: 1214
  • ULTIMATE ROOKIE
    • View Profile
Re: replacing terrain graphics, bmp-->pck issue (Hobbes ?)
« Reply #12 on: June 27, 2014, 10:16:55 pm »
It's likely. For working with images, it's conventional to use "lime" or "pink" as the "transparent color" because it makes it easier to tell the background apart from the sprite.

In OpenXcom the color you use as the "transparent color" in your palette doesn't really matter because it uses "color 0" as the transparent color, not an RGB, so SDL will automatically figure it out when matching extraSprites with the original palettes/graphics.

However there's no guarantee that other programs will behave the same. If they are matching by RGB, you will have to change the first palette color to RGB 0,0,0.
I actually already tried that. But it then uses white, instead of that black, for the transparent color.
Also it seems to me that pckview it doesn't use 'pure black' (0, 0, 0) as its transparent color: when you convert .pck files to .bmp using it, the transparent color is 'replaced' instead by a very dark blue-ish-black.
I looked into it too much since I wanted to finish an armor, but I will in the following days.

Also: do you know how to convert .aco swatches into .act color tables? When I try to save directly a color table, it includes only the colors effectively used in the image (photoshop CS4) instead of the whole color table.

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2159
    • View Profile
Re: replacing terrain graphics, bmp-->pck issue (Hobbes ?)
« Reply #13 on: June 28, 2014, 12:12:52 am »
I actually already tried that. But it then uses white, instead of that black, for the transparent color.
Also it seems to me that pckview it doesn't use 'pure black' (0, 0, 0) as its transparent color: when you convert .pck files to .bmp using it, the transparent color is 'replaced' instead by a very dark blue-ish-black.
I looked into it too much since I wanted to finish an armor, but I will in the following days.

Also: do you know how to convert .aco swatches into .act color tables? When I try to save directly a color table, it includes only the colors effectively used in the image (photoshop CS4) instead of the whole color table.
Dunno, the way I use palettes in Photoshop is to set an image to Image > Mode > Indexed Color, and then I can load and alter the palette in Image > Mode > Color Table. As long as you don't optimize the image, the full 256-color palette should be preserved.

Offline AndO3131

  • Colonel
  • ****
  • Posts: 137
    • View Profile
Re: replacing terrain graphics, bmp-->pck issue (Hobbes ?)
« Reply #14 on: June 28, 2014, 09:52:50 am »
This could be another candidate for unhardcoding - 'battlescapeTerrainData' entries
Code: [Select]
      mapDataSets:
        - BLANKS
        - U_EXT02
        - U_WALL02
        - U_BITS
      mapBlocks:
        - name: UFO_110
          width: 10
          length: 10
could be expanded in future 'resource' entry.