Visual Basic Wiki
Register
Advertisement
WHY
===

A few months ago there was a CGA wallpaper thread. Someone mentioned something along the lines of "I wish I had a program that did this automatically, like a screensaver or suchlike, for when I'm feeling nostalgic." I happened to share the sentiment and I couldn't let go of the idea so I finally decided to implement it. For now, here's the .exe, but I plan on releasing the source, if I can think of a good name and clean up the code. Suggestions for names are welcome, as are suggestions on how to open-source-ify stuff. Interface not in English for now, but it's simple and you're all very good with languages, no?

GETTING STARTED
===============

Runtime libraries may need some Googling. Should work on anything from Windows 95 onwards.
	If you get a message about VB40032.dll try here:
	http://support.microsoft.com/default.aspx?scid=kb;EN-US;q196286


First schrollbar is the background color, second the palette.
Doubleclick the image for fullscreen mode.
Rightclick the image for a contextmenu.
	Paste expects a filename on the clipboard.
	Copy allows you to transfer the dithered image to a drawing app.
		Due to technical reasons this does not yet work properly while the app is still busy.
Global shortcut keys:
	up-arrow - next folder
	down-arrow - pause
	left/right-arrow - previous/next image in history
Fullscreen extra shortcut key:
	escape - return to the small window (clicking yield the same effect)

OPTIONS
=======

<path to program>.exe /<options> <file/folder>
	C:\...\CGADither.exe D:\...\Image.jpg
	C:\...\CGADither.exe /f D:\My documents\My pictures
	C:\...\CGADither.exe /fs D:\My documents\Screensaver
Commandline options are mostly available in the GUI as well.
Both /fs and /f /s are legal syntax. Use /b1a or /b1 /a for arguments that need a value.

a - turns off autopalette
	Normally when it loads an image by itself (from the commandline or in slideshow mode) it tries to autodetect the palette. This option makes it use whatever palette is currently selected.
b - specifies the selected background colour on program startup; range: [0, 15]
c - specifies the colourpalette; range: [0, 3]
	If you've specified a file or folder on the commandline you'll need to specify a as well otherwise these two options are ignored.
d - always try the dark palettes as well
	The dark palettes are always going to look like crap unless the image is very dark so for images it loads by itself it normally doesn't even try them (to save time). This option turns that behaviour off.
e - diffusionfactor; range: [0, 250]
	This is the coefficient of error diffusion:
	Really low values turn dithering off (0) or almost off.
	Low values lead to artifacts, but sometimes better detail.
	High values lead to good dithering (defaults to 230) but a wrong palette may cause small blownout areas.
	Really high values lead to excellent dithering if the palette is right. But with CGA for some images there is no right palette and large blownout areas may appear.
f - start in fullscreen mode
	Without this it will start as a small window where you can adjust settings and such.
h - number of images in history; range: [0, really big]
	It keeps a small history of images so that if you see a good image, you can go back. This determines how many images are kept in the history. Defaults to 8.
i - interval for slideshow mode in milliseconds; range: [0, 65535]
	Defaults to 5000, maximum is just over a minute. If you set this value low it may happen that the images don't change as often as you want. Using the a option will help, but at a price.
p - start paused
	Normally when you specify a folder rather than a single file on the command line it will go in slideshow mode. Specify this option to start paused.
s - (expiremental) screensaver mode
	Closes the program on mouse movement or keypress
h or ? - display a list of supported options

NOTES, QUESTIONS YOU MIGHT ASK AND SUCH
=======================================

For dithering it uses an error diffusion method. Usually yields good results, but in gradients sometimes "worms" may appear. This is a common problem of error diffusion filters.

It was programmed in a very short timeframe. It may be very buggy. However, it will hopefully not modify your pictures, so can try it somewhat safely. At worst you'll get an error dialog with "Runtime error 69. You're not paying attention." or some similar message.

Currently it handles JPEG and 24-bit bitmap, where the largest 4:3 box is at least 320 pixels wide. It assumes square pixels in the source even though the output pixels aren't.

Why does it look like crap?
	It's CGA. Deal with it.

Why does it take so long before the next image appears in slideshow mode?
	Dithering in one palette is quite fast, but when automatic palettte detection is active it needs to try all 26 (or even 52) palettes and that is slow.

Why does the first image show in multiple palettes?
	Most of the time the first palette tested will work. This means that for the first image loaded this gets displayed to have something on screen that will probably be what was displayed anyway and otherwise look reasonable.

Why do blownout areas appear, or cyan bits near eyes etc? Why is the colour of part of the image off?
	The algoritm is quite stupid and not able to discern which bits of an image are important and which are details or background. That would not be a trivial programming task. The only thing it does is try to match the colours of the image as best it can. Images likely to display the problem are for example images with a small figure and a large differently coloured backround or zoom layer.

Why do palette 2 and 4 yield crappy results?
	Because they are very dark. So dark that the bounding box of the colours in these palettes cannot hope to capture the gamut of all but the darkest images.

Why can't I find any CGA dating sims on the internet?
	Because a) CGA was not popular in Japan and b) CGA was dead and buried by the time dating sims became popular. A shame, because the black-cyan-magenta-white palette would have been ideal and you could probably have fitted about 80 images on one disk.
Advertisement