16e7d3316Smrg
26e7d3316SmrgREADME.MSW	hedu@cul-ipn.uni-kiel.de	5/94
36e7d3316Smrg
46e7d3316Smrg		The XPM library for MS-Windows
597cf2ee2Smrg
66e7d3316SmrgMotivated by the wxWindows library, which is a (freely available) toolkit
797cf2ee2Smrgfor developing multi-platform, graphical applications from the same body
897cf2ee2Smrgof C++ code, I wanted to have XPM pixmaps for MS-windows. Instead of rewriting
96e7d3316Smrga XPM-parser I managed to port the XPM-library-code to MS-windows.
106e7d3316SmrgThanks to Anaud Le Hors this became a part of the official XPM-library.
116e7d3316Smrg
1297cf2ee2SmrgUntil now it's only used together with wxWindows. And even there it's more
1397cf2ee2Smrga kind of beta. But it should be possible to run it as a simple libxpm.a
146e7d3316Smrgwithout wxWindows.
156e7d3316Smrg
166e7d3316SmrgThe key is a transformation of some X types plus some basic X functions.
176e7d3316SmrgThere is not yet a special MSW-API, so you should know the X types used.
186e7d3316Smrg
196e7d3316SmrgThe following is done in simx.h:
206e7d3316Smrg
216e7d3316Smrgtypedef HDC Display;
226e7d3316Smrgtypedef COLORREF Pixel;
236e7d3316Smrg
246e7d3316Smrgtypedef struct {
256e7d3316Smrg    Pixel pixel;
266e7d3316Smrg    BYTE red, green, blue;
276e7d3316Smrg}      XColor;
286e7d3316Smrg
296e7d3316Smrgtypedef struct {
306e7d3316Smrg    HBITMAP bitmap;
316e7d3316Smrg    unsigned int width;
326e7d3316Smrg    unsigned int height;
336e7d3316Smrg    unsigned int depth;
346e7d3316Smrg}      XImage;
356e7d3316Smrg
366e7d3316SmrgWith these defines and the according functions from simx.c you can call
376e7d3316SmrgXPM-functions the way it's done under X windows. It can look like this:
386e7d3316Smrg
3997cf2ee2Smrg	ErrorStatus=XpmCreateImageFromData(&dc, data,
406e7d3316Smrg				&ximage,(XImage **)NULL, &xpmAttr);
416e7d3316Smrg	ms_bitmap = ximage->bitmap;
426e7d3316Smrg	// releases the malloc,but do not destroy the bitmap
436e7d3316Smrg	XImageFree(ximage);
4497cf2ee2Smrg
456e7d3316SmrgSupported functions are the Xpm*Image* but not the Xpm*Pixmap*.
466e7d3316Smrg
476e7d3316SmrgDRAWBACKS:
486e7d3316SmrgThe main drawback is the missing support for Colormaps! There was nothing for
496e7d3316Smrgit in wxWindows, so I did not know how to deal with Colormaps.
506e7d3316Smrg
516e7d3316SmrgThe size of the pixmaps is bounded by malloc() (width*height*2 < 64K).
526e7d3316Smrg
536e7d3316SmrgClose colors do not look that close. But that seems to be the window system.
546e7d3316Smrg
556e7d3316SmrgNeither a special API for MSW nor a special MSW documentation other than this.
566e7d3316Smrg(I can only point you to wxxpm as an example , see below.)
576e7d3316Smrg
586e7d3316SmrgINSTALLATION:
596e7d3316SmrgThere is not yet a makefile with it. Simply take all the *.c files
606e7d3316Smrginto your project except the files related to Pixmap operations: *P*.c.
616e7d3316Smrg!!!You MUST set FOR_MSW on the preprocessor options!!!
626e7d3316Smrg(You might uncomment NEED_STRCASECMP in xpm.h if it's in your lib)
636e7d3316SmrgThis should compile into libxpm.a. Good luck...
646e7d3316Smrg
6597cf2ee2SmrgFTP:
666e7d3316SmrgwxWindows is currently available from the Artificial Intelligence
676e7d3316SmrgApplications Institute (University of Edinburgh) by anonymous FTP.
686e7d3316Smrg	skye.aiai.ed.ac.uk  pub/wxwin/
696e7d3316Smrgor read http://burray.aiai.ed.ac.uk/aiai/aiai.html
706e7d3316Smrg
716e7d3316Smrgwxxpm, XPM support for wxWindows, the latest version is available at
726e7d3316Smrg	yoda.cul-ipn.uni-kiel.de pub/wxxpm/
736e7d3316Smrg	and maybe in the contrib or tools of wxWindows
7497cf2ee2Smrg
756e7d3316SmrgPlease contact me if you have suggestions, comments or problems!
766e7d3316Smrg
776e7d3316Smrg================================================================
786e7d3316SmrgSome fixes and comments by Jan Wielemaker (jan@swi.psy.uva.nl),
796e7d3316SmrgOct 24, 1996:
806e7d3316Smrg
816e7d3316Smrg	* Please try not to disturb me on this, XPM is not my
826e7d3316Smrg	piece of cake.
836e7d3316Smrg
8419569120Smrg	* Hermann Dunkel has apparently moved in virtual space.
856e7d3316Smrg
866e7d3316SmrgChanges:
876e7d3316Smrg
886e7d3316Smrg	* I've used the xpm package under NT 4.0 and MSVC++ 4.2.
896e7d3316Smrg
9097cf2ee2Smrg	* I've made a big performance improvement in
916e7d3316Smrg	ParseAndPutPixels(), fixed creation of the mask in
926e7d3316Smrg	SetColor() in create.c.  I looked into XCreateImage()
936e7d3316Smrg	in simx.c, but commented out my improvement for reasons
946e7d3316Smrg	you'll find there.  If you know what is going on, statement
956e7d3316Smrg	(1) does not apply to you.
966e7d3316Smrg
976e7d3316SmrgComments on installation:
986e7d3316Smrg
996e7d3316Smrg	* Donot include the to/from pixmap files into the project.
1006e7d3316Smrg	These are the ones containing a capital P somewhere in their
1016e7d3316Smrg	name.  You can also first include all, and then remove all
1026e7d3316Smrg	the files you get errors on :-)
1036e7d3316Smrg
1046e7d3316Smrg	* The DC that is requested should be a valid memory DC, thus
1056e7d3316Smrg	CreateCompatibleDC(NULL) provides a good generic one, but
1066e7d3316Smrg	GetDC(NULL) doesn't!  This costed me some time.
1076e7d3316Smrg
1086e7d3316Smrg	* The real difficulty is using the mask, mostly due to the
1096e7d3316Smrg	bad documentation.  If 95 or NT is your target, use:
1106e7d3316Smrg
1116e7d3316Smrg	MaskBlt(context.hdc,	// Destination DC
1126e7d3316Smrg		x, y, w, h,	// Destination area
1136e7d3316Smrg		mhdc,		// Memory DC with the image selected
1146e7d3316Smrg		sx, sy,		// Source X,Y
1156e7d3316Smrg		msk,		// HBITMAP of the mask
1166e7d3316Smrg		sx, sy,		// Mask X,Y
1176e7d3316Smrg		MAKEROP4(SRCPAINT, SRCCOPY));	// The magic op code.
1186e7d3316Smrg================================================================
1196e7d3316Smrg
1206e7d3316Smrg
1216e7d3316Smrg--
1226e7d3316Smrg   ////|\\\\   \\\\\\  Hermann Dunkel
1236e7d3316Smrg     O   O     //////  IPN Uni Kiel, Germany
1246e7d3316Smrg       |       \\\\\\  Tel: +49 431 / 880 3144
1256e7d3316Smrg     \___/     //////  E-mail: hedu@cul-ipn.uni-kiel.de
1266e7d3316Smrg      \_/      \\\\\\  X.400 : c=de;a=d400;p=uni-kiel;ou=nw-didaktik;s=dunkel
1276e7d3316Smrg
128