-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxwd.h
128 lines (108 loc) · 3.45 KB
/
xwd.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#ifndef xwd_h
#define xwd_h
/* $Id: xwd.h,v 1.11 2019/03/01 18:25:16 dkl Exp $ */
#include <X11/Xlib.h>
#include <X11/Xmd.h>
#include <X11/XWDFile.h>
#include <stdio.h>
#define MAXLN 512 // longest line of input text we allow
#define NEW_IMAGE_NAME "new.xwd"
#define DEFAULT_FONT "6x9.bdf"
#define DEFAULT_FONT_DPI "misc"
#define DEFAULT_FONT_PATH "/usr/local/share/fonts" // where we install bdfs
#define min(x,y) (((x) < (y)) ? (x) : (y))
#define max(x,y) (((x) > (y)) ? (x) : (y))
typedef unsigned long Pixel;
typedef unsigned short Color;
class xwd {
public:
xwd (const char *name); // for use with images which have no DPI
xwd (); // for creating an image from scratch
~xwd ();
int MakeBW(); // make black-and-white
int Use4(); // make 4-bit data
int Use8(); // make 8-bit data
int Resize (int, int);
int Halve ();
int Sample ();
int Crop (int, int, int, int);
int Fill (int, int, int, int);
void Clear ();
void Set ();
void Trim();
void TrimLeft();
void TrimRight();
void TrimTop();
void TrimBottom();
void DumpHeader ();
void DumpImage ();
void DumpLine (int line=0);
void Dump();
int Scale (double);
int ReadXWD (int);
int DontReadXWD ();
int WriteXWD ();
void DumpCmap(int cells=255);
int SquishCmap();
int TruncCmap(int);
int SetWhitePixel(Pixel);
int SetBlackPixel(Pixel);
int SwapBW();
int SetBackground(Pixel);
int SetForeground(Pixel);
int SetForeground(char *);
int Uniq();
int AddColor(char *);
int AddColor(XColor *);
int AddColor(int, int, int);
int HasColor(XColor *);
Pixel GetColor (int r, int g, int b);
Pixel GetColor (char *);
int ReadRGB (char *colorname, int *r, int *g, int *b);
int FindRGBByName (char *);
static int NumRGBs ();
static int lsColors();
void MergeCmap(xwd *intoMe);
void MapTo(xwd *toMe);
void DrawBorder (const char *borderName);
int DrawLines (char *);
void DrawLine (int, int, int, int);
void DrawRect (int, int, int, int);
unsigned ImageSize ();
void DrawString(char *text, int x, int y, int alignment);
Pixel GetPixel (register int x, register int y);
void PutPixel (register int x, register int y, Pixel pix);
void SetName (char *);
void SetPath (char *);
void SetFont (char *);
void SetFontPath (char *);
void SetFontFamily (char *);
void SetFontStyle (char *);
void SetFontPT (char *);
void SetFontDPI (char *);
void SetPenWidth (unsigned long setting) {penWidth=setting;}
int GetClosestColor (int r, int g, int b);
int GetFarthestColor (int r, int g, int b);
int ShowFonts ();
int ListPath (char *);
//void SetVerbose (Bool setting) {verbose = setting;};
void Error (const char *);
char *name, *path;
XImage *image;
XWDFileHeader *header;
XColor *colors;
int ncolors;
unsigned long whitePixel, blackPixel, fg, bg, penWidth;
char *font, *fontPath, *fontDPI, *family, *pt, *style;
Bool debug, verbose, writeGzipped;
private:
Bool Read (char *ptr, int size, int nitems, FILE *stream);
void DrawSteepLine (int, int, int, int);
void DrawShallowLine (int, int, int, int);
static void _swapshort (char *, unsigned);
static void _swaplong (char *, unsigned);
};
#define sameColor(c1, c2) ((c1.red == c2.red) && \
(c1.green == c2.green) && \
(c1.blue == c2.blue))
#endif /* xwd_h */