Author Topic: Converting VGA images to EGA  (Read 8953 times)

Offline Nol Drek

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2177
    • Nol Drek's Web Site
Converting VGA images to EGA
« on: April 12, 2015, 09:38:21 PM »
Does anyone know of an easy method for converting VGA images to EGA without having to recolor the image pixel by pixel?

I know that there must be some algorithm hidden within the Gold Box games, since they were able to run on a machine in either mode, EGA or VGA. The algorithm is definitely not a nearest color substitution, as Vix mentioned in the thread about Goldbox PC icons.

As an example, take a look at the two images below. These are NOT images that I have recolored or touched up in any way. They are simply screen caps from the first scene of "Gateway to the Savage Frontier" running in DOS Box in VGA mode and then again in EGA mode.

If a computer in 1989 could take the single image and alter it at run time to work with either graphic adapter, it seems that there must be a simple way to automate the process of image conversion.
"Into the Drachensgrab Mountains!"

http://www.noldrek.com

Offline Adam

  • Full Member
  • ***
  • Posts: 111
Re: Converting VGA images to EGA
« Reply #1 on: April 13, 2015, 09:14:12 AM »
While it is clearly not nearest color substitution, it still looks like color substitution on the first glance. I guess there is a mapping matrix which works for all the art used in one particular game. This means it will most probably not work on art from another source.

Edit: I doubt there is an easy automatic way to achieve a similar result. Some colors with higher values are mapped to darker colors. I'm sure these images were made to be portable to EGA.
« Last Edit: April 13, 2015, 09:23:19 AM by Adam »

Offline hans

  • Hero Member
  • *****
  • Posts: 2716
Re: Converting VGA images to EGA
« Reply #2 on: April 13, 2015, 03:24:18 PM »
The example above may well have been a case of an artist VGA-ing an original EGA image. 

The reason I think this may be the case is that there is no loss of any important detail in the image, rather it appears just a simpler (flatter) execution. 

For an image that starts VGA and is then translated to EGA, there are often visual problems that cannot be easily translated.  Evidence of such translations is often found in stray pixels that serve no purpose, or objects rendered confusingly or left out entirely.

Offline Null Null

  • Maker of excessively difficult vanilla mods
  • Hero Member
  • *****
  • Posts: 567
Re: Converting VGA images to EGA
« Reply #3 on: April 13, 2015, 06:05:17 PM »
Ever played Pools of Darkness in EGA? it looks awful. My guess is they were doing some sort of pixel lookup table or algorithm.

One thing I did notice about the pictures in TSF, now that you mention it, is they tend to have shading within the same colors only--you don't see changes from brown to red to yellow, for example, as is done with many of the pics in POD. It could be this was done on purpose to allow for better EGA conversion. Can anyone with a little more knowledge comment?

Offline Nol Drek

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2177
    • Nol Drek's Web Site
Re: Converting VGA images to EGA
« Reply #4 on: April 14, 2015, 10:28:01 PM »
This next set of images was screen capped using Goldbox Explorer.

The image in Treasures of the Savage Frontier uses about 80 colors.
In Gateway to the Savage Frontier, the same image uses about 32 colors.
In Neverwinter Nights, the same image only uses the 16 EGA colors.

If the EGA image was created first, and then more detail was added to areas of solid color as the palette became larger, as hans suggests, then it should be possible to map those colors back to the original EGA palette.
"Into the Drachensgrab Mountains!"

http://www.noldrek.com

Offline ProphetSword

  • Mod Designer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2900
  • FRUA Lives!
    • Lands of Adventure
Re: Converting VGA images to EGA
« Reply #5 on: April 15, 2015, 10:15:39 AM »
While not exactly as old-school EGA as the original pictures, I took the images you uploaded and converted them to 16-colors (no dithering) in Irfanview.  The results look nice (perhaps nicer than the original EGA), but might not capture what you want.  My thought is once they are 16 colors, it might just be a matter of adjusting the palette to match everything else, though.

Here are the results:
LANDS OF ADVENTURE: An Old-School Style CRPG

More Information Here: http://landsadventure.blogspot.com/

Offline ProphetSword

  • Mod Designer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2900
  • FRUA Lives!
    • Lands of Adventure
Re: Converting VGA images to EGA
« Reply #6 on: April 15, 2015, 11:31:17 AM »
I found that using Photoshop, I could take these pictures and reduce them to 16-colors using an indexed color scheme, but it actually only uses 8 colors (see picture 1 of the giant that is using only 8 colors).

However, when I told it to use 40 colors, it reduced the palette to 16 colors (not sure why that is), and got a very close approximation of the original EGA artwork (see pictures 2 and 3).  It isn't exact, but the colors look nice and it actually looks like an EGA rendering.

If you want more information about it, let me know.  It may or may not suit your needs.
LANDS OF ADVENTURE: An Old-School Style CRPG

More Information Here: http://landsadventure.blogspot.com/

Offline Nol Drek

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2177
    • Nol Drek's Web Site
Re: Converting VGA images to EGA
« Reply #7 on: April 15, 2015, 08:46:24 PM »
The same thing happens to me when I try to use an Image Processing Program - either some of the flesh tones get converted to shades of gray, or else some of the colors get muddied. I have better luck using the Color Replacement Tool manually.

The GSF images only use 32 colors, so I only have to replace 16 of the colors with colors from the EGA palette. The TSF and POD images that use 64+ colors take even more time.

I was hoping for a simple palette substitution where I could maintain the indexes and have all the flesh tones become Bright Red (255, 85, 85), Brown (170, 85, 0), or Red (170, 0, 0).
"Into the Drachensgrab Mountains!"

http://www.noldrek.com

Offline ProphetSword

  • Mod Designer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2900
  • FRUA Lives!
    • Lands of Adventure
Re: Converting VGA images to EGA
« Reply #8 on: April 16, 2015, 07:31:51 AM »
I tried replicating the palette in Photoshop.  Copied colors from one to another until I ended up with an exact copy.  Then, I applied that palette to another picture to see what would happen.  Didn't work.  Skin colors were closer, but they still didn't look like the original picture.  Other colors were just wrong.

Are you sure there's an algorithm in play?  Is it possible that there are both EGA and VGA versions of the artwork stored in the game?
LANDS OF ADVENTURE: An Old-School Style CRPG

More Information Here: http://landsadventure.blogspot.com/

Offline Adam

  • Full Member
  • ***
  • Posts: 111
Re: Converting VGA images to EGA
« Reply #9 on: April 16, 2015, 09:52:27 AM »
Are you sure there's an algorithm in play?  Is it possible that there are both EGA and VGA versions of the artwork stored in the game?

Based on the images in this thread I certain there is (though the GSF ogre/giant has some minor changes in detail). I'll check some more images this weekend if I can find a general mapping LUT, though I'm not sure if it makes any sense. It would only work on pieces which were created from EGA ones, thus it is probably totally in vain...
« Last Edit: April 16, 2015, 09:54:40 AM by Adam »

Offline Null Null

  • Maker of excessively difficult vanilla mods
  • Hero Member
  • *****
  • Posts: 567
Re: Converting VGA images to EGA
« Reply #10 on: April 16, 2015, 05:38:27 PM »
I'm not that good a programmer, but it seems like the sort of thing that would be pretty easy if you knew what you were doing; take every pair of EGA and VGA pics that correspond and have the computer output the most likely EGA pixel for a given VGA pixel, summed over the entire GSF/TSF set.

Offline ProphetSword

  • Mod Designer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2900
  • FRUA Lives!
    • Lands of Adventure
Re: Converting VGA images to EGA
« Reply #11 on: April 17, 2015, 07:53:22 AM »
Given that most of these pictures don't use the full spectrum of colors (I think they fall somewhere between 30-80 colors), the algorithm probably matches whole groups of colors to one specific color.  So, all light "flesh" shades would be one color, all darker "flesh" shades would be another.  All greens would be one green color, etc.  That makes sense.
LANDS OF ADVENTURE: An Old-School Style CRPG

More Information Here: http://landsadventure.blogspot.com/

Offline Nol Drek

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2177
    • Nol Drek's Web Site
Re: Converting VGA images to EGA
« Reply #12 on: April 17, 2015, 04:53:49 PM »
A general mapping look-up table would be an awesome solution to this problem.

Using the Ogre/Giant pic as an example, it would be something along the lines of:

247, 165, 115 -> 255,  85,  85
247, 132,  99 -> 255,  85,  85
198,  82,  66 -> 170,   0,   0
132,  49,  40 -> 170,   0,   0
 66,   0,   0 ->   0,   0,   0


I could make use of such a table regardless of whether it is in decimal (as above) or in hex to completely automate the process of image conversion.

Unfortunately, I don't know enough about the DAX format to inspect the graphics directly. I have to use Goldbox Explorer to inspect the images. Goldbox Explorer is a great tool, truly invaluable, but the palettes it creates are not 100% accurate.
"Into the Drachensgrab Mountains!"

http://www.noldrek.com

Offline Null Null

  • Maker of excessively difficult vanilla mods
  • Hero Member
  • *****
  • Posts: 567
Re: Converting VGA images to EGA
« Reply #13 on: April 17, 2015, 11:37:10 PM »
Write a script that screencaps Goldbox Explorer and dumps to .bmp? Once it's a 2-D array the problem seems easy enough, the difficulty is getting there.

How about the old DAXVIEW/DAXVGA programs? As I recall, they just put up the pictures, one by one, and you moved through them with the spacebar. If there's a way to capture the pictures from them...
« Last Edit: April 18, 2015, 08:52:22 AM by Null Null »

Offline Nol Drek

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2177
    • Nol Drek's Web Site
Re: Converting VGA images to EGA
« Reply #14 on: April 18, 2015, 10:59:57 AM »
DAXVIEW and DAXVGA don't work with small pics from GSF, TSF, and POD.
"Into the Drachensgrab Mountains!"

http://www.noldrek.com