PDA

View Full Version : EGA (enhanced graphics adapter)



dr.zeissler
June 11th, 2015, 04:57 AM
Hi,

how do I convert graphics from any kind of colour-deph and format to ega-gif with the ega-palette in the best possible quality ? (perhaps with dithering filter?)
For generating the Pics I have a PII-333/512/Dos/Win98se/Win2k
For watching I use a 286/10/EGA and cshow.

Thx
Doc

Plasma
June 11th, 2015, 06:02 AM
Paint Shop Pro 6 can do this (psp602.exe is the shareware version). Choose Windows palette when reducing to 16 colors. Error diffusion dither will probably look the best on photos.

Stone
June 11th, 2015, 06:25 AM
Irfanview (http://www.irfanview.com/) will do this and almost anything else you want to do. It's very easy to use, small and if you've never used it you really should try it out. Plus it's free for non-commercial use.

Scali
June 11th, 2015, 07:02 AM
I think 'best possible quality' is a bit of a problem:
If you go for 640x350 mode, you can choose any 16 colours from the total palette of 64 colours (2:2:2 bit RGB).
So you'll need to convert the image in 2 steps:
1) Find the most suitable 16 colours from the total of 64.
2) Find the best mapping of the image to these 16 colours (using dithering).

I guess step 1 would be more of a colour reduction approach, after which you would sort the colours on frequency. Perhaps using median cut or something.
An interesting problem is whether you would 'merge' two colours that are close together, yet both reasonably frequent.

dr.zeissler
June 11th, 2015, 07:35 AM
exact! First is the Resolution Problem. Finding 640x350 ART (not Photos) indicates that they are mostly EGA itself.
That means the most targets are 640x400 or 640x480. Reducing the size means convertig the 16 Color VGA Art or 256 Color VGA-Art to true Color and converting to 640x350. This indicates that the image itself is changed (streched).

After that the palette must be reduced to the EGA 6Bit palette. And the Colors must be reduced to 16 at the same time. That is the most interesting part, because the are many ways to do that. You described some. What about letting a special filter caclculating patterns in order to simulate more colors. That is a procedure that most Sierra/Lucas Adventures did for their Backgrounds.

There are only a few real EGA Images in the Inernet available. Mostly they were done/created with EGA. Converting potential Images that have itself not so much colors could be very exciting. Possible target (Amiga/Atari Images with 16/32 Colors, ore some early VGA-Art with 16 or 256 colors.

Doc

dr.zeissler
June 11th, 2015, 07:44 AM
...one more thing :)

how do I change the palette to real EGA? all programs that were mentioned do not have the option EGA-Palette.
Reducing to 16 colors with Irfanview means 16 Colors out of the VGA-Palette with 262.000 Colors.

Palette/Colors
8Bit/256 out of 262.000
6Bit/16 out of 64

So how do I do this?

Thx
Doc

PS: In a german forum someone told me to due this with a "posterize-effect", but this does not help either because
I don't know what program and how-to.

krebizfan
June 11th, 2015, 08:29 AM
No matter what tool is used, unless you are willing to do a lot of work, some images will come out of the process looking very strange.

Posterization is available in Photoshop. I suspect that Irfanview with all of its plugins should do the same. Good chance that it will happen automatically with some other converters. Posterization is just a term for the planned reduction of the number of colors with ranges of colors being replaced with the closest member of smaller result set. Smart dithering would look better on average but sometimes will result in hilariously awful results.

You don't have to reduce the pixel count. Convert to fewer colors but leave the image size the same. You will only see the top 3/4 of the image and have to scroll to see the bottom. In some cases, that will suffice.

Have you tried CShow to see if it will display images designed for higher resolution displays? I remember PC Paintbrush would do the adjustments automatically transforming the VGA images I downloaded into EGA equivalents. I know there were other tools that did the same but my EGA system got retired more than a decade ago and I don't have the tools I used to use anymore.

Scali
June 11th, 2015, 09:46 AM
You have to take into account that 640x350 may be the same size on screen as 640x480 is on VGA.
The spacing of the scanlines is just different. So you have to resize in order to get the same aspect ratio on screen, else it will look stretched on EGA.

dr.zeissler
June 11th, 2015, 09:59 AM
cshow shows not all lines if a 640x400/16 image is displayed on EGA as 640x350/16.
https://www.flickr.com/photos/94839221@N05/16244253082/in/album-72157649803051477/

dr.zeissler
June 16th, 2015, 04:04 AM
the last days I experimented with vga2ega.exe (version 3.0), this old tool has some tuning-options in it,
but the results did not convice me. if I choose "ordered palette" in Photoshop with 16 colors I get nearly
the same results.

Perhaps the easiest way is to choose a "master-pic" and some people try to make a real EGA-GIF 640x350
out of it and we compare the results?

"vga2ega" only works directly on diskette, otherwise I get a "out of memory error".

dr.zeissler
June 17th, 2015, 01:04 AM
I got it yesterday. I used Paintshop Pro Version 5.

Converting 640x400 or 640x480 to 640x350 is a bit difficult. better option is to cut 640x350 out of 640x400/480, but that depends on the picture.
cshow displays every converted picture with the correct aspect ratio on an EGA-Screen. Therfore some lines were not displayd. If there is Text at
the left out line it does not look so nice. I will try to cut or make the Picture smaller by adding black space so the aspect ratio can be the same.

The key for converting is the EGA-Palett-File. I loaded the Picture of the EGA-Palette (PNG) and changed von indexed-color to true color.
Then I was able to extract the 64color-pal. out of the picture.

I now load a VGA-picture and after that I load the EGA-pal and now I have many options to convert the picture.
At the end I choose reducing to 16 out of the 64 and save it as a gif.

For good results it is really important, that the material has only a few colors. the best results are pictures with
16 VGA colors. So I do not have to add dithering and can choose "nearest color". If I do so, only a few details
get lost. Otherwise I had to dither in order to keep the picture-details.

I am currently looking for good VGA16-Color Material. I found out that old japanese-systems had such gfx.
(PC98?). Perhaps someone has some internetsites with 16color pc98 artworks.

Doc :)

Trixter
June 17th, 2015, 08:02 AM
I think your biggest hurdle is finding a program that can remap+dither to EGA's special-case 16-out-of-64-color palette. There weren't a lot of programs that could deal with that well, but I think CSHOW could. Once you find a program that can do that, saving it to a file is easy (either take a screenshot using DOSBOX, or take a "native" screenshot on the system using Screen Thief or PCXDMP or something).

dr.zeissler
June 17th, 2015, 09:16 AM
Dithering makes sense if i can control what spaces are dithered, but that is not possible without full editing the picture. but that is not my goal.
therefore I choose Pictures with low VGA-Colors that are dithered before, so I need only mapping to the nearest color and make no dithering.

critical are skin-colors and details that are in greytones, but I have managed some conversation that are quite good. I will upload the new EGA
Pictures later. I also made the choice that 640x350 is the maximum, so no larger pictures. Mostly I cuted the new Picture out of the old one.
That was quite simple with PaintShopPro5. It is a really good and small program.

Doc

Scali
June 17th, 2015, 10:40 AM
I think your biggest hurdle is finding a program that can remap+dither to EGA's special-case 16-out-of-64-color palette.

This is actually one of the projects on my way-too-long todo-list: an image processing/conversion tool capable of optimizing images for oldskool platforms with their various limitations. Such as C64 character/sprite-based modes, CGA hi-colour modes, Amiga HAM, EGA, VGA etc.
As a coder, part of the problem is always to convert 'modern' image data to the memory layout of a vintage system. But having a preprocessor that is fine-tuned to also do the colour reduction and mapping to special palettes and other trickery would make the tool even more powerful.
So at some point I would like to implement a few colour reduction and dithering algorithms, and have a flexible pipeline to convert any kind of modern truecolour image to a vintage platform as optimally as possible.

Trixter
June 17th, 2015, 11:54 AM
An admirable goal, but be prepared for some deep research -- most available information/algorithms regarding color reduction and dithering assume uniform/linear colorspaces for both the source and target (or worse, the exact same colorspace for both source and target). It gets unclear what to do when your target colorspace differs from the source and you want to dither. Without dithering, it's fairly easy to pick which 16 of the available 64 EGA colors match best -- but since dithering changes the distributed error, how to pick the colors for dithering?

Because EGA is limited to 64 total colors, the search space is pretty small -- on modern systems you could probably get away with iterating through dithering the picture against all 488526937079580 palette combinations and picking the one with the least measurable error (preferably against a visual metric like SSIM). But HAM6, with its unique artifacting, couldn't be done this way.

dr.zeissler
June 17th, 2015, 12:36 PM
So here is the new collection so far... I am working on some other GFX-stuff "PC-98"
https://www.flickr.com/photos/94839221@N05/sets/72157652364100484

Some Images are well known, but not with the EGA-Palette. I have not tested all Pictures on the real machine, but I am sure they will be exactly the same.

So here is the goal: Pick 10 of your favorites and make an EGA-Slideshow with music and stutterfree scrolling of the pics and if you wish a scroller text...just kidding :)

Scali
June 17th, 2015, 01:05 PM
An admirable goal, but be prepared for some deep research -- most available information/algorithms regarding color reduction and dithering assume uniform/linear colorspaces for both the source and target (or worse, the exact same colorspace for both source and target).

Don't worry, I studied computer graphics and signal processing in university :)


but since dithering changes the distributed error, how to pick the colors for dithering?

Sometimes the only way is bruteforce (like the CGA tool).
I know there are some tools for Atari 8-bit that bruteforce a ton of colours to try and get the best match for a given image.
You don't always need the 'perfect' image of course. I generally prefer algorithms that are 'good enough' by using some smart heuristics to make them perform in (near-)realtime.


But HAM6, with its unique artifacting, couldn't be done this way.

Yes, that's why I want to make a tool for this sort of thing... Certain modes have very unique characteristics, and there's no way you can properly prepare an image with PhotoShop or other modern tools.
In the case of HAM, there are basically 4 ways to pick each colour: Pick a colour from the 16-entry palette, or take the previous colour and replace the R, G, or B component.

So you have two problems here:
1) Which 16 colours do you pick for the palette?
2) For each pixel, which of the 4 possibilities is the best pick?

The interesting part with 2) is that it leads to a sort of error propagation... It may well be possible that choosing a less optimal colour for one pixel leads to less errors in subsequent pixels. So perhaps some kind of 'greedy' algorithm, trying to match a group of pixels at a time is best.

A common trick with HAM6/HAM8 is to just divide the horizontal resolution by 3, and then use 3 commands to set R, G and B separately. That means every third pixel is the correct RGB value.
Simple, but effective.

dr.zeissler
June 17th, 2015, 11:21 PM
is there some sort of "toolbox" available that I could build an ega-slideshow by myself ?

Trixter
June 18th, 2015, 06:46 AM
Any number of "slideshow" or "presentation" packages made for DOS will do this. GRASP is a common shareware one; although others (ftp://ftp.oldskool.org/pub/misc/Software/Graphics/Presentation/) were my favorite.

dr.zeissler
June 18th, 2015, 07:48 AM
Any number of "slideshow" or "presentation" packages made for DOS will do this. GRASP is a common shareware one; although others (ftp://ftp.oldskool.org/pub/misc/Software/Graphics/Presentation/) were my favorite.

Thx, I'll check them later.

Someone on a german board reminded me of the other aspect ratio of ega to vga.
I did not have checked the pictures that have been cut out of the original image for that.
If I have to correct the aspect ratio in order to get sqares then I will have to do
some converting that will easily cost a lot of quality of the converted image.

I'll check this too.

Trixter
June 18th, 2015, 08:30 AM
If I have to correct the aspect ratio in order to get sqares then I will have to do
some converting that will easily cost a lot of quality of the converted image.


There is no good way to fix this because EGA high-res pixel art was composed for its native aspect ratio. Most conversions will ruin the image. It is usually best to just display 640x350 pictures as-is.

If you want to try fixing the aspect ratio anyway, use nearest neighbor (point) resizing to (640*3)x(350*4) or 1920x1400 which will convert to square pixels while retaining the crisp nature of pixel art. You can then resize smaller if you like using a smoother algorithm like lanczos or bicubic. But this is only for displaying on the web.

dr.zeissler
June 18th, 2015, 02:37 PM
The aspect ratio is a bit of a problem while watching the cut-out-images on the real machine :(
With some images it is quite obvious that there is something wrong with the proportions. If I resize the source-material I need to go for true color and that makes them look good, but this produces "antialiasing" which causes a lot of problems when reducing to 6Bit color! the image is not crisp anymore, there are details lost and that is not my intention.

the question is, are there better ways to get a real good EGA Image out of low-color VGA 640x400/640x480 source-material.

Doc

Trixter
June 18th, 2015, 04:04 PM
the question is, are there better ways to get a real good EGA Image out of low-color VGA 640x400/640x480 source-material.

Nope.

dr.zeissler
June 18th, 2015, 09:11 PM
there are some real 640x200 images in the source material, so there are three different aspects.

Source 640x400
Source 640x480
Source 640x200

Yesterday I tested some ways to correct the aspect for the EGA Monitor. I changed the Monitor itself a bit.

I think I will only change a view of the pics, because mostly you don't recognize the false aspect.
It is harder to deal with the quality issues, then with the false aspect ratio.

Doc

Stone
June 19th, 2015, 02:21 AM
Why don't you post one of the pics you're working with so we can see what this is all about. Just u/l one original. Don't post it on the forum directly as the board's software will manipulate it before we get a look at it. Post it on a host site with a link.

dr.zeissler
June 19th, 2015, 10:44 AM
Please test if you get access (https://www.dropbox.com/sh/yjyct5vkgidkpyw/AAAiiIt1lXCS_ufE3JpJ0Y3ua?dl=0) to it.

Trixter
June 19th, 2015, 10:57 AM
What is your goal? Is it your goal to display these properly on the web, or properly on an EGA 640x350 monitor?

dr.zeissler
June 19th, 2015, 11:03 AM
Goals

1. Display them with the correct aspect on the real machine (EGA Monitor 640x350). If that's not possible without seeing quality issues then the cut out version will be the one to display on the real machine.
2. Make an EGA-Hires Slideshow (perhaps with music and scrolling text)
3. Questions about this:
- Is a starfield in EGA-Hires possible
- Is a stutterfree scroller in EGA-Hires possible
- Can the gfx-file scrolled in (stutterfree)
- Does the FPU do any job for it, or is it not accessible/useable?

I am currently searching the web for pascal-source file, because I ha euro-pascal here on my 286.

Doc

Stone
June 19th, 2015, 11:09 AM
Please test if you get access (https://www.dropbox.com/sh/yjyct5vkgidkpyw/AAAiiIt1lXCS_ufE3JpJ0Y3ua?dl=0) to it.Geez.... I don't get it! I said ONE!!! :-)

And besides... these pics are ALREADY 16 colors!!!!! What the hell are you trying to do?

krebizfan
June 19th, 2015, 11:34 AM
Based on the images uploaded, you will not be able to adjust them to maintain aspect ratio and look similar to the original. For example, ALTAIR6.GIF will probably wind up looking like a checkerboard as all the star pixels combine into lines. So many pixel width elements are just guaranteed to defeat virtually any automatic conversion program.

2) Making a EGA HiRes slideshow is doable but you should strive for EGA original images or post a note saying that the images are inspired by Warhol transforming the errors in conversion into an artistic statement.

3) Starfield: Have seen that before
Stutterfree: very difficult but I have seen it before
FPU: Probably won't provide any help in converting or displaying graphics

dr.zeissler
June 19th, 2015, 11:34 AM
no dithering, therefore good good quality. vga16 colors mostly not ega16 colors.
try cd2 from the 400. i do not get the text uncorrupted if i correct the aspect ratio to get the cd round again on an ega monitor.

krebizfan
June 19th, 2015, 11:39 AM
Maybe post a set of images: original and what you get when you convert. It may just be what you want is nearly impossible and the conversions you get are close to the best that can be made automatically. Hand revising would be necessary to fix the flaws of the conversion.

Trixter
June 19th, 2015, 12:03 PM
1. Display them with the correct aspect on the real machine (EGA Monitor 640x350). If that's not possible without seeing quality issues then the cut out version will be the one to display on the real machine.
2. Make an EGA-Hires Slideshow (perhaps with music and scrolling text)
3. Questions about this:
- Is a starfield in EGA-Hires possible
- Is a stutterfree scroller in EGA-Hires possible
- Can the gfx-file scrolled in (stutterfree)
- Does the FPU do any job for it, or is it not accessible/useable?


1. You know this is already impossible, so just display them 1:1 and either crop, center, or scroll them. 640x200x16 works on EGA. Search compuserve GIF archives from the 1980s, there were hundreds of nice 640x350 pictures floating around BBSes at that time.

3. Yes, Yes, Yes, FPU is not used. But I'm not going to code it for you. The slideshow programs I linked to previously may do this correctly.

dr.zeissler
June 19th, 2015, 03:00 PM
Don't get me wrong, I'll try to code something for myself.

Trixter
June 19th, 2015, 04:35 PM
Then you'll likely need to find this: http://www.amazon.com/Programmers-Guide-Super-Cards-Edition/dp/0201624907
It was considered the best reference for all EGA features back in its day.

dr.zeissler
June 19th, 2015, 11:24 PM
Don't laugh...I got the "Turbo Pascal 7.0" Compendium here and searched for demofiles(.pas) for "starfield" and "scroller"
Though the programmers-guide book looks very interesting, but I think that I will not understand it... but I'll checkout if I get it somewhere.

btw. I never saw any demos/intros/scroller/starfields in Hires-EGA. perhaps there are currently none, but the idea is great :)

krebizfan
June 19th, 2015, 11:44 PM
May not be demos but a variety of Windows 3.0 screen savers and hDC's tiny game Rocks provided smooth scrolling and starfields with HiRes EGA (10 MHz 286). If it can be done with Windows overhead, doing it with DOS should be possible.

Scali
June 20th, 2015, 01:19 AM
May not be demos but a variety of Windows 3.0 screen savers and hDC's tiny game Rocks provided smooth scrolling and starfields with HiRes EGA (10 MHz 286). If it can be done with Windows overhead, doing it with DOS should be possible.

I suppose they just bypassed Windows completely then. The Windows graphics API has no support for smooth scrolling. In fact, I don't think even DirectDraw had support for scrolling. You'd just do it 'bruteforce' by blitting your whole screenbuffer.
So I suppose they just set up a fullscreen EGA environment and banged the hardware directly, just like in DOS. Because a 286 with EGA wouldn't be fast enough for anything bruteforce.

dr.zeissler
June 20th, 2015, 02:26 AM
To get into the material, I first read this one: http://www.minuszerodegrees.net/oa/OA%20-%20IBM%20Enhanced%20Graphics%20Adapter.pdf
Then I have an Assembler-Book for "8086/8088/80186/80286" an the TurboPascal7-Book and I have someone who studies "IT".
But this guy told me weeks ago, that they do "java" etc. but that is not what I call "assembler-programming" but as you know, I have no clue.

krebizfan
June 20th, 2015, 07:22 AM
Michael Abrash had a series of articles regarding fast graphics on EGA printed in Programmer's Journal in 1987 and 1988 though the later parts started switching over to a focus on VGA. Good enough that a couple of game developers used the techniques presented there. Several erstwhile online libraries have copies of it which should be easy to find with a search.

dr.zeissler
June 20th, 2015, 10:23 AM
are you talking about this?: http://www.phatcode.net/res/224/files/html/index.html

krebizfan
June 20th, 2015, 10:36 AM
The book you point includes the revised VGA versions of the articles. Some mentions of the differences between EGA and the VGA superset of same are included but the focus is not on EGA.

For the EGA version, look at http://www.pcjs.org/pubs/pc/magazines/

dr.zeissler
June 20th, 2015, 11:14 AM
Thx!!

dr.zeissler
June 20th, 2015, 11:07 PM
btw. http://cd.textfiles.com/simtelctc/disk1/EGA/
64Colors at once :) (EGACOLRS)

...currently reading those EGA articles...must search for external help, because unknown stuff with unknown words...pretty heavy. But I think I'll get help soon. I have already spoke to someone how knows about programming, but I don't know yet how good his knowlegde is.

dr.zeissler
December 25th, 2015, 09:15 AM
http://wab.com

I don't know how they did these things, but especially the atari-st stuff is really nice. only 16 colors out of 512 and no hardwarescrolling,
but stutterfree software softscolling, very impressive.

I did not see anything like that on EGA, even on VGA there no such things.