ubb-vga version 2, more image sources and better color mapping
David Kuehling
dvdkhlng at gmx.de
Thu Apr 28 05:59:28 EDT 2011
>>>>> "Werner" == Werner Almesberger <werner at almesberger.net> writes:
> ubb-vga2 has learned a few new tricks: First of all, it can now
> generate a test image (ubb-vga2 -t), which looks like this:
> http://downloads.qi-hardware.com/people/werner/ubb/vga/ubb-vga2-tstimg.jpg
Werner, you're a genious. Zooming into the image, I can't see see any
dithering. How did you manage that many colors?
> The test image reveals a number of bugs:
> The diagonal lines should cross exactly at the edge of the display
> area. We can see that a few pixels are missing on the left and at the
> bottom. The top is good but hard to see in this picture. The smears on
> the right are just stale data.
> This test image also shows that the new board has twice the number of
> colors: a lavish 16 of them !
> The horizontal timing jitters by about one pixel time, which makes the
> small text on the color bar difficult to read. There is also a
> distortion at the top, which indicates that the beginning of the frame
> is not exactly synchronized with the rest.
> The next improvement is better color mapping. I originally used a
> simple threshold-based algorithm that would only consider one channel
> a time and that didn't know of the new luminance channel.
> The new algorithm assigns a position in the RGB color cube for each
> screen color and then searches for the closest color for every
> pixel. I'll let the result speak for itself:
You might want to have a look at the color lookup code used in the
allegro game library (alleg.sf.net). They used a 2^5 x 2^5 x 2^5 lookup
table for RGB -> palette color mapping, quickly precumputed by using a
3-dimensional floodfill algorithm [1]. Allegro gives you a bitmap data
type [2] that allows lowlevel access to bitmap memory, so maybe you could
directly use that.
Allegro's blit() [3] routine can copy between bitmaps of diffferent color
depth, optionally doing dithering. There's also stretch_blit() for
scaling (albeit without interpolation?). Allegro only supports
8-bit-per-pixel in paletted modes, but if you just set 256-16 colors to
black, there shouldn't be a problem. All of this is pretty optimized
code.
Plus you already have code for loading files into bitmaps (bmp, tga or
pcx).
cheers,
David
[1] http://alleg.sourceforge.net/latestdocs/en/alleg021.html#bestfit_color
[2] http://alleg.sourceforge.net/latestdocs/en/alleg001.html#BITMAP
[3] http://alleg.sourceforge.net/latestdocs/en/alleg014.html#blit
--
GnuPG public key: http://user.cs.tu-berlin.de/~dvdkhlng/dk.gpg
Fingerprint: B17A DC95 D293 657B 4205 D016 7DEF 5323 C174 7D40
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.en.qi-hardware.com/pipermail/discussion/attachments/20110428/6658b06a/attachment.pgp>
More information about the discussion
mailing list