RE: XForms: grayscale images (repeated)

Orn E. Hansen (oe.hansen@oehansen.pp.se)
Mon, 29 Sep 1997 14:40:44 +0200 (CEST)

To subscribers of the xforms list from "Orn E. Hansen" <oe.hansen@oehansen.pp.se> :

=DEann 23-Sep-97 skrifar "John Prinos"r:
>=20
> I am currently running ver0.75 XForms on Redhat linux ver4.1 using 16 b=
it
> colour.
>=20
> I am trying, for proof of concept, to show an 8 bit greyscale image. I =
get an
> X-window error: BADMATCH when I try to show the image. It seems to work=
if
> Redhat is in 8 bit mode.
>=20
> [ snip ]
>=20
> Any comments would be appreciated, I apologize for the hacked code but =
i just
> wanted to see if this was possible.
>=20

An 8-bit image, has each pixel on the screen as 1-byte in memory. So,
before you can display that image on a 16-bit color depth, where each pix=
el
is 2-byte in memory, you have to do a conversion. There are probably man=
y
ways to do this and those that are far better than this one (xearth is on=
e
program that does this, it uses an 8-bit image and converts it to 1,15,16=
,
24 or 32 bits depending on the visual).

Basically you could take every byte in your source image...

10011010

and duplicate each bit

1100001111001100

Which I think would be reasonably accurate, and whereafter you would ha=
ve
a picture suitable for a 16 bit visual.

Hope that helps...

-------------------------------------------------------------------------=

---
Orn Einar Hansen                         oe.hansen@oehansen.pp.se
                                          oehansen@daimi.aau.dk
                                        voice+fax; +46 035 217194
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
Xforms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/