X11 Work Bench Toolkit  1.0
pixmap_helper.h
1 
2 // _ _ _ _ //
3 // _ __ (_)__ __ _ __ ___ __ _ _ __ | |__ ___ | | _ __ ___ _ __ | |__ //
4 // | '_ \ | |\ \/ /| '_ ` _ \ / _` || '_ \ | '_ \ / _ \| || '_ \ / _ \| '__|| '_ \ //
5 // | |_) || | > < | | | | | || (_| || |_) | | | | || __/| || |_) || __/| | _ | | | | //
6 // | .__/ |_|/_/\_\|_| |_| |_| \__,_|| .__/_____|_| |_| \___||_|| .__/ \___||_|(_)|_| |_| //
7 // |_| |_| |_____| |_| //
8 // //
9 // pixmap and icon helpers (ultimately providing universal support) //
10 // //
12 
13 /*****************************************************************************
14 
15  X11workbench - X11 programmer's 'work bench' application and toolkit
16  Copyright (c) 2010-2016 by Bob Frazier (aka 'Big Bad Bombastic Bob')
17  all rights reserved
18 
19  DISCLAIMER: The X11workbench application and toolkit software are supplied
20  'as-is', with no warranties, either implied or explicit.
21  Any claims to alleged functionality or features should be
22  considered 'preliminary', and might not function as advertised.
23 
24  BSD-like license:
25 
26  There is no restriction as to what you can do with this software, so long
27  as you include the above copyright notice and DISCLAIMER for any distributed
28  work that is equal to or derived from this one, along with this paragraph
29  that explains the terms of the license if the source is also being made
30  available. A "derived work" describes a work that uses a significant portion
31  of the source files or algorithms that are included with this one.
32  Specifically excluded from this are files that were generated by the software,
33  or anything that is included with the software that is part of another package
34  (such as files that were created or added during the 'configure' process).
35  Specifically included is the use of part or all of any of the X11 workbench
36  toolkit source or header files in your distributed application. If you do not
37  ship the source, the above copyright statement is still required to be placed
38  in a reasonably prominent place, such as documentation, splash screens, and/or
39  'about the application' dialog boxes.
40 
41  Use and distribution are in accordance with GPL, LGPL, and/or the above
42  BSD-like license. See COPYING and README files for more information.
43 
44 
45  Additional information at http://sourceforge.net/projects/X11workbench
46 
47 ******************************************************************************/
48 
49 
50 #ifndef _PIXMAP_HELPER_H_
51 #define _PIXMAP_HELPER_H_
52 
53 #include "window_helper.h" // if not already included, I must include this
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif // __cplusplus
58 
59 
60 #define ID_ICON_FIRST 101
61 #define ID_APPLICATION 101 /* 19x19 application icon */
62 #define ID_ICON_OK 102
63 #define ID_ICON_STOP 103
64 #define ID_ICON_WARN 104 /* yellow triangle, ! */
65 #define ID_ICON_WHAT 105
66 #define ID_ICON_QUESTION 105
67 #define ID_ICON_SPLAT 106
68 #define ID_ICON_ASTERISK 106
69 #define ID_ICON_BANG 107 /* yellow circle, ! */
70 #define ID_ICON_TRIANGLE 108
71 #define ID_ICON_WHAT_BOLD 109
72 #define ID_ICON_WTF 110
73 #define ID_ICON_DEATH 111
74 #define ID_ICON_FINGER 112
75 #define ID_ICON_SKULL 113
76 #define ID_ICON_THUMBUP 114
77 #define ID_ICON_THUMBDOWN 115
78 #define ID_ICON_BEAR 116
79 #define ID_ICON_BARNEY 117
80 #define ID_ICON_APP 118 /* 36x36 application icon */
81 #define ID_ICON_LAST 118 /* must alter this if new items added */
82 
83 
95 #define RGB255_TO_XCOLOR(R,G,B,X) { (X).red = ((unsigned int)(R) << 8) & 0xffff; \
96  (X).green = ((unsigned int)(G) << 8) & 0xffff; \
97  (X).blue = ((unsigned int)(B) << 8) & 0xffff; \
98  (X).flags = DoRed | DoGreen | DoBlue; }
99 
111 #define RGB_TO_XCOLOR(R,G,B,X) { (X).red = ((unsigned int)(R)) & 0xffff; \
112  (X).green = ((unsigned int)(G)) & 0xffff; \
113  (X).blue = ((unsigned int)(B)) & 0xffff; \
114  (X).flags = DoRed | DoGreen | DoBlue; }
115 
116 
145 void PXM_RGBToYUV(int iR, int iG, int iB, int *piY, int *piU, int *piV);
146 
175 void PXM_YUVToRGB(int iY, int iU, int iV, int *piR, int *piG, int *piB);
176 
177 
188 void PXM_PixelToRGB(XStandardColormap *pMap, XColor *pColor);
189 
190 
202 void PXM_RGBToPixel(XStandardColormap *pMap, XColor *pColor);
203 
204 
217 void PXM_RegisterAppIcons(char *ppRegAppLarge[], char *ppRegAppSmall[]);
218 
219 
232 int PXM_RegisterPixmapResource(Atom aResource, char *ppResource[]);
233 
234 
235 
249 Pixmap PXM_GetIconPixmap(int idIcon, XPM_ATTRIBUTES *pAttr, Pixmap *pMask /* = NULL*/);
250 
251 
265 Pixmap PXM_GetIconPixmapFromAtom(Atom aIcon, XPM_ATTRIBUTES *pAttr, Pixmap *pMask /* = NULL*/);
266 
267 
268 
284 Pixmap PXM_LoadPixmap(char *ppXPM[], XPM_ATTRIBUTES *pAttr, Pixmap *pMask /* = NULL*/);
285 
286 
287 
307 Pixmap PXM_ImageToPixmap(Display *pDisplay, Drawable dw, XImage *pImage,
308  unsigned long clrFGPixel, unsigned long clrBGPixel);
309 
310 
311 
330 Pixmap PXM_ImageToPixmap0(Display *pDisplay, Drawable dw, XImage *pImage);
331 
332 
333 
351 XImage *PXM_PixmapToImage(Display *pDisplay, Pixmap pxImage);
352 
353 
354 
355 
363 void PXM_OnExit(void);
364 
365 
366 //--------------------
367 // HELPERS FOR XImage
368 //--------------------
369 
370 
382 static __inline void *PXM_GetImageDataPtr(XImage *pImage)
383 {
384  return pImage->data;
385 }
386 
398 static __inline unsigned long PXM_GetImageDataLength(XImage *pImage)
399 {
400  if(pImage->depth <= 1)
401  {
402  return (unsigned long)pImage->bytes_per_line * (unsigned long)pImage->height; // TODO: is this right?
403  }
404 
405  return (unsigned long)pImage->bytes_per_line * (unsigned long)pImage->height
406  * (unsigned long)pImage->depth;
407 }
408 
409 
410 #ifdef __cplusplus
411 };
412 #endif // __cplusplus
413 
414 #endif // _PIXMAP_HELPER_H_
415