1 // Scintilla source code edit control
3 ** Define a classes to hold image data in the X Pixmap (XPM) and RGBA formats.
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.
16 * Hold a pixmap in XPM format.
22 std::vector
<unsigned char> pixels
;
23 ColourDesired colourCodeTable
[256];
25 ColourDesired
ColourFromCode(int ch
) const;
26 void FillRun(Surface
*surface
, int code
, int startX
, int y
, int x
) const;
28 explicit XPM(const char *textForm
);
29 explicit XPM(const char *const *linesForm
);
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
, const 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;
39 static std::vector
<const char *>LinesFormFromTextForm(const char *textForm
);
43 * A translucent image stored as a sequence of RGBA bytes.
49 std::vector
<unsigned char> pixelBytes
;
51 RGBAImage(int width_
, int height_
, float scale_
, const unsigned char *pixels_
);
52 explicit RGBAImage(const XPM
&xpm
);
53 // Deleted so RGBAImage objects can not be copied.
54 RGBAImage(const RGBAImage
&) = delete;
55 RGBAImage
&operator=(const RGBAImage
&) = delete;
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);
68 * A collection of RGBAImage pixmaps indexed by integer id.
71 typedef std::map
<int, std::unique_ptr
<RGBAImage
>> ImageMap
;
73 mutable int height
; ///< Memorize largest height of the set.
74 mutable int width
; ///< Memorize largest width of the set.
78 /// Remove all images.
81 void Add(int ident
, RGBAImage
*image
);
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.