diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-11-28 17:26:37 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-12-09 10:43:20 +0100 |
| commit | 36cd0a397c6d8fee7ffc5b59d607ead523226e53 (patch) | |
| tree | 91f0bd3628ae3d7b7553706b24b66b1bb4620c6b /FL | |
| parent | 0bb30d8f92839af826fb389fccd625c74e981a13 (diff) | |
New Fl_ICO_Image class to read Windows .ico icon files
Many thanks to @darealshinji for contributing all the code
for this new FLTK image class (see branch Fl_ICO_Image of https://github.com/darealshinji/fltk).
Diffstat (limited to 'FL')
| -rw-r--r-- | FL/Fl_BMP_Image.H | 4 | ||||
| -rw-r--r-- | FL/Fl_ICO_Image.H | 55 | ||||
| -rw-r--r-- | FL/Fl_PNG_Image.H | 7 |
3 files changed, 61 insertions, 5 deletions
diff --git a/FL/Fl_BMP_Image.H b/FL/Fl_BMP_Image.H index 63dd301df..462d61957 100644 --- a/FL/Fl_BMP_Image.H +++ b/FL/Fl_BMP_Image.H @@ -1,7 +1,7 @@ // // BMP image header file for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2021 by Bill Spitzak and others. +// Copyright 1998-2022 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -34,7 +34,7 @@ public: protected: - void load_bmp_(class Fl_Image_Reader &rdr); + void load_bmp_(class Fl_Image_Reader &rdr, int ico_height = 0, int ico_width = 0); }; diff --git a/FL/Fl_ICO_Image.H b/FL/Fl_ICO_Image.H new file mode 100644 index 000000000..9693cc545 --- /dev/null +++ b/FL/Fl_ICO_Image.H @@ -0,0 +1,55 @@ +// +// ICO image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// http://www.fltk.org/COPYING.php +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +// https://en.wikipedia.org/wiki/ICO_(file_format) +// http://www.daubnet.com/en/file-format-ico + +#ifndef Fl_ICO_Image_H +# define Fl_ICO_Image_H +# include "Fl_BMP_Image.H" + +/** + The Fl_ICO_Image class supports loading, caching, and drawing of Windows icon (.ico) files. + */ +class FL_EXPORT Fl_ICO_Image : public Fl_BMP_Image { + +public: + /** Windows ICONDIRENTRY structure */ + struct IconDirEntry { + int bWidth; ///< Image width + int bHeight; ///< Image height + int bColorCount; ///< Number of colors (0 if ≥ 8bpp) + int bReserved; ///< Reserved + int wPlanes; ///< Color Planes + int wBitCount; ///< Bits per pixel + int dwBytesInRes; ///< Resource size in bytes + int dwImageOffset; ///< Offset to the image + }; + + Fl_ICO_Image(const char *filename, int id = -1, const unsigned char *data = NULL, const size_t datasize = 0); + ~Fl_ICO_Image(); +/** Gives the number of icons of various resolutions present in the ICO object */ + int idcount() { return idcount_; } + /** Returns the array of idcount() loaded IconDirEntry structures */ + IconDirEntry * const icondirentry() const { return icondirentry_; } + +private: + int idcount_; + struct IconDirEntry *icondirentry_; + void load_ico_(class Fl_Image_Reader &rdr, int id); +}; + +#endif // Fl_ICO_Image_H diff --git a/FL/Fl_PNG_Image.H b/FL/Fl_PNG_Image.H index f0910a515..1b5e32179 100644 --- a/FL/Fl_PNG_Image.H +++ b/FL/Fl_PNG_Image.H @@ -1,7 +1,7 @@ // // PNG image header file for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2021 by Bill Spitzak and others. +// Copyright 1998-2022 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -28,13 +28,14 @@ and alpha-based transparency. */ class FL_EXPORT Fl_PNG_Image : public Fl_RGB_Image { - + friend class Fl_ICO_Image; public: Fl_PNG_Image(const char* filename); Fl_PNG_Image (const char *name_png, const unsigned char *buffer, int datasize); private: - void load_png_(const char *name_png, const unsigned char *buffer_png, int datasize); + Fl_PNG_Image(const char *filename, int offset); // used by Fl_ICO_Image + void load_png_(const char *name_png, int offset, const unsigned char *buffer_png, int datasize); }; // Support functions to write PNG image files (since 1.4.0) |
