Fix action icons in the log dialog being clipped on High-DPI displays
[TortoiseGit.git] / ext / scintilla / src / XPM.h
blob6d3530b9cb5b162f950aa1c252b1b57bcd8e0a74
1 // Scintilla source code edit control
2 /** @file XPM.h
3 ** Define a classes to hold image data in the X Pixmap (XPM) and RGBA formats.
4 **/
5 // Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
8 #ifndef XPM_H
9 #define XPM_H
11 #ifdef SCI_NAMESPACE
12 namespace Scintilla {
13 #endif
15 /**
16 * Hold a pixmap in XPM format.
18 class XPM {
19 int height;
20 int width;
21 int nColours;
22 std::vector<unsigned char> pixels;
23 ColourDesired colourCodeTable[256];
24 char codeTransparent;
25 ColourDesired ColourFromCode(int ch) const;
26 void FillRun(Surface *surface, int code, int startX, int y, int x) const;
27 public:
28 explicit XPM(const char *textForm);
29 explicit XPM(const char *const *linesForm);
30 ~XPM();
31 void Init(const char *textForm);
32 void Init(const char *const *linesForm);
33 /// Decompose image into runs and use FillRectangle for each run
34 void Draw(Surface *surface, PRectangle &rc);
35 int GetHeight() const { return height; }
36 int GetWidth() const { return width; }
37 void PixelAt(int x, int y, ColourDesired &colour, bool &transparent) const;
38 private:
39 static std::vector<const char *>LinesFormFromTextForm(const char *textForm);
42 /**
43 * A translucent image stored as a sequence of RGBA bytes.
45 class RGBAImage {
46 // Deleted so RGBAImage objects can not be copied
47 RGBAImage(const RGBAImage &) = delete;
48 RGBAImage &operator=(const RGBAImage &) = delete;
49 int height;
50 int width;
51 float scale;
52 std::vector<unsigned char> pixelBytes;
53 public:
54 RGBAImage(int width_, int height_, float scale_, const unsigned char *pixels_);
55 explicit RGBAImage(const XPM &xpm);
56 virtual ~RGBAImage();
57 int GetHeight() const { return height; }
58 int GetWidth() const { return width; }
59 float GetScale() const { return scale; }
60 float GetScaledHeight() const { return height / scale; }
61 float GetScaledWidth() const { return width / scale; }
62 int CountBytes() const;
63 const unsigned char *Pixels() const;
64 void SetPixel(int x, int y, ColourDesired colour, int alpha=0xff);
67 /**
68 * A collection of RGBAImage pixmaps indexed by integer id.
70 class RGBAImageSet {
71 typedef std::map<int, RGBAImage*> ImageMap;
72 ImageMap images;
73 mutable int height; ///< Memorize largest height of the set.
74 mutable int width; ///< Memorize largest width of the set.
75 public:
76 RGBAImageSet();
77 ~RGBAImageSet();
78 /// Remove all images.
79 void Clear();
80 /// Add an image.
81 void Add(int ident, RGBAImage *image);
82 /// Get image by id.
83 RGBAImage *Get(int ident);
84 /// Give the largest height of the set.
85 int GetHeight() const;
86 /// Give the largest width of the set.
87 int GetWidth() const;
90 #ifdef SCI_NAMESPACE
92 #endif
94 #endif