diff options
Diffstat (limited to 'FL')
| -rw-r--r-- | FL/Fl_BMP_Image.H | 6 | ||||
| -rw-r--r-- | FL/Fl_GIF_Image.H | 8 | ||||
| -rw-r--r-- | FL/Fl_Image.H | 162 | ||||
| -rw-r--r-- | FL/Fl_JPEG_Image.H | 10 |
4 files changed, 92 insertions, 94 deletions
diff --git a/FL/Fl_BMP_Image.H b/FL/Fl_BMP_Image.H index 09ce85717..5f0c30118 100644 --- a/FL/Fl_BMP_Image.H +++ b/FL/Fl_BMP_Image.H @@ -24,9 +24,9 @@ # include "Fl_Image.H" /** - The Fl_BMP_Image class supports loading, caching, - and drawing of Windows Bitmap (BMP) image files. -*/ + The Fl_BMP_Image class supports loading, caching, + and drawing of Windows Bitmap (BMP) image files. + */ class FL_EXPORT Fl_BMP_Image : public Fl_RGB_Image { public: diff --git a/FL/Fl_GIF_Image.H b/FL/Fl_GIF_Image.H index 3548880e7..a24079a8e 100644 --- a/FL/Fl_GIF_Image.H +++ b/FL/Fl_GIF_Image.H @@ -24,10 +24,10 @@ # include "Fl_Pixmap.H" /** - The Fl_GIF_Image class supports loading, caching, - and drawing of Compuserve GIF<SUP>SM</SUP> images. The class - loads the first image and supports transparency. -*/ + The Fl_GIF_Image class supports loading, caching, + and drawing of Compuserve GIF<SUP>SM</SUP> images. The class + loads the first image and supports transparency. + */ class FL_EXPORT Fl_GIF_Image : public Fl_Pixmap { public: diff --git a/FL/Fl_Image.H b/FL/Fl_Image.H index e099741c1..a4d6d737d 100644 --- a/FL/Fl_Image.H +++ b/FL/Fl_Image.H @@ -30,26 +30,36 @@ class Fl_Pixmap; struct Fl_Menu_Item; struct Fl_Label; + /** \enum Fl_RGB_Scaling - The scaling algorithm to use for RGB images. + The scaling algorithm to use for RGB images. */ enum Fl_RGB_Scaling { - FL_RGB_SCALING_NEAREST = 0, ///< default RGB image scaling algorithm - FL_RGB_SCALING_BILINEAR ///< more accurate, but slower RGB image scaling algorithm + FL_RGB_SCALING_NEAREST = 0, ///< default RGB image scaling algorithm + FL_RGB_SCALING_BILINEAR ///< more accurate, but slower RGB image scaling algorithm }; + /** - Fl_Image is the base class used for caching and - drawing all kinds of images in FLTK. This class keeps track of - common image data such as the pixels, colormap, width, height, - and depth. Virtual methods are used to provide type-specific - image handling. + \brief Base class for image caching and drawing. + + Fl_Image is the base class used for caching and drawing all kinds of images + in FLTK. This class keeps track of common image data such as the pixels, + colormap, width, height, and depth. Virtual methods are used to provide + type-specific image handling. - Since the Fl_Image class does not support image - drawing by itself, calling the draw() method results in - a box with an X in it being drawn instead. + Since the Fl_Image class does not support image + drawing by itself, calling the draw() method results in + a box with an X in it being drawn instead. */ class FL_EXPORT Fl_Image { + +public: + const int ERR_NO_IMAGE = -1; + const int ERR_FILE_ACCESS = -2; + const int ERR_FORMAT = -3; + +private: int w_, h_, d_, ld_, count_; const char * const *data_; static Fl_RGB_Scaling RGB_scaling_; @@ -58,19 +68,19 @@ class FL_EXPORT Fl_Image { Fl_Image & operator=(const Fl_Image &); Fl_Image(const Fl_Image &); - protected: +protected: /** - Sets the current image width in pixels. - */ + Sets the current image width in pixels. + */ void w(int W) {w_ = W;} /** - Sets the current image height in pixels. - */ + Sets the current image height in pixels. + */ void h(int H) {h_ = H;} /** - Sets the current image depth. - */ + Sets the current image depth. + */ void d(int D) {d_ = D;} /** Sets the current line data size in bytes. @@ -85,85 +95,88 @@ class FL_EXPORT Fl_Image { static void labeltype(const Fl_Label *lo, int lx, int ly, int lw, int lh, Fl_Align la); static void measure(const Fl_Label *lo, int &lw, int &lh); - public: +public: /** Returns the current image width in pixels. - */ + */ int w() const {return w_;} - /** Returns the current image height in pixels. + /** + Returns the current image height in pixels. */ int h() const {return h_;} /** - Returns the current image depth. + Returns the current image depth. The return value will be 0 for bitmaps, 1 for - pixmaps, and 1 to 4 for color images.</P> - */ + pixmaps, and 1 to 4 for color images.</P> + */ int d() const {return d_;} /** - Returns the current line data size in bytes. - Line data is extra data that is included - after each line of color image data and is normally not present. - */ + Returns the current line data size in bytes. + Line data is extra data that is included + after each line of color image data and is normally not present. + */ int ld() const {return ld_;} /** - The count() method returns the number of data values - associated with the image. The value will be 0 for images with - no associated data, 1 for bitmap and color images, and greater - than 2 for pixmap images. - */ + The count() method returns the number of data values + associated with the image. The value will be 0 for images with + no associated data, 1 for bitmap and color images, and greater + than 2 for pixmap images. + */ int count() const {return count_;} /** - Returns a pointer to the current image data array. - Use the count() method to find the size of the data array. - */ + Returns a pointer to the current image data array. + Use the count() method to find the size of the data array. + */ const char * const *data() const {return data_;} - /** - The constructor creates an empty image with the specified - width, height, and depth. The width and height are in pixels. - The depth is 0 for bitmaps, 1 for pixmap (colormap) images, and - 1 to 4 for color images. - */ - Fl_Image(int W, int H, int D) {w_ = W; h_ = H; d_ = D; ld_ = 0; count_ = 0; data_ = 0;} + Returns a value that is not 0 if there is currently no image + available. + \return ERR_NO_IMAGE if no image was found + \return ERR_FILE_ACCESS if there was a file access related error (errno should be set) + \return ERR_FORMAT if image decoding failed. + */ + int fail(); + Fl_Image(int W, int H, int D); virtual ~Fl_Image(); virtual Fl_Image *copy(int W, int H); /** - The copy() method creates a copy of the specified - image. If the width and height are provided, the image is - resized to the specified size. The image should be deleted (or in - the case of Fl_Shared_Image, released) when you are done - with it. - */ + The copy() method creates a copy of the specified + image. If the width and height are provided, the image is + resized to the specified size. The image should be deleted (or in + the case of Fl_Shared_Image, released) when you are done + with it. + */ Fl_Image *copy() { return copy(w(), h()); } virtual void color_average(Fl_Color c, float i); /** - The inactive() method calls - color_average(FL_BACKGROUND_COLOR, 0.33f) to produce - an image that appears grayed out. + The inactive() method calls + color_average(FL_BACKGROUND_COLOR, 0.33f) to produce + an image that appears grayed out. - An internal copy is made of the original image before - changes are applied, to avoid modifying the original image. - */ + An internal copy is made of the original image before + changes are applied, to avoid modifying the original image. + */ void inactive() { color_average(FL_GRAY, .33f); } virtual void desaturate(); virtual void label(Fl_Widget*w); virtual void label(Fl_Menu_Item*m); /** - Draws the image with a bounding box. - Arguments <tt>X,Y,W,H</tt> specify - a bounding box for the image, with the origin - (upper-left corner) of the image offset by the \c cx - and \c cy arguments.\n + Draws the image with a bounding box. + Arguments <tt>X,Y,W,H</tt> specify + a bounding box for the image, with the origin + (upper-left corner) of the image offset by the \c cx + and \c cy arguments. + In other words: <tt>fl_push_clip(X,Y,W,H)</tt> is applied, the image is drawn with its upper-left corner at <tt>X-cx,Y-cy</tt> and its own width and height, <tt>fl_pop_clip</tt><tt>()</tt> is applied. - */ + */ virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0); // platform dependent /** - Draws the image. - This form specifies the upper-lefthand corner of the image. - */ + Draws the image. + This form specifies the upper-lefthand corner of the image. + */ void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} // platform dependent virtual void uncache(); @@ -174,6 +187,7 @@ class FL_EXPORT Fl_Image { static Fl_RGB_Scaling RGB_scaling(); }; + /** The Fl_RGB_Image class supports caching and drawing of full-color images with 1 to 4 channels of color information. @@ -206,25 +220,9 @@ public: unsigned mask_; // for internal use (mask bitmap) #endif // __APPLE__ || WIN32 - public: +public: -/** - The constructor creates a new image from the specified data. - \param[in] bits The image data array. - \param[in] W The width of the image in pixels - \param[in] H The height of the image in pixels - \param[in] D The image depth, or 'number of channels'. Default=3<br> - If D=1, each uchar in bits[] is a grayscale pixel value.<br> - If D=2, each uchar pair in bits[] is a grayscale + alpha pixel value.<br> - If D=3, each uchar triplet in bits[] is an R/G/B pixel value<br> - If D=4, each uchar quad in bits[] is an R/G/B/A pixel value. - \param[in] LD Line data size (default=0).<br> - Line data is extra data that is included after each line - of color image data and is normally not present. - \see Fl_Image::data(), Fl_Image::w(), Fl_Image::h(), Fl_Image::d(), Fl_Image::ld() - */ - Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0) : - Fl_Image(W,H,D), array(bits), alloc_array(0), id_(0), mask_(0) {data((const char **)&array, 1); ld(LD);} + Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0); Fl_RGB_Image(const Fl_Pixmap *pxm, Fl_Color bg=FL_GRAY); virtual ~Fl_RGB_Image(); virtual Fl_Image *copy(int W, int H); diff --git a/FL/Fl_JPEG_Image.H b/FL/Fl_JPEG_Image.H index f79452380..d9b162c13 100644 --- a/FL/Fl_JPEG_Image.H +++ b/FL/Fl_JPEG_Image.H @@ -24,11 +24,11 @@ # include "Fl_Image.H" /** - The Fl_JPEG_Image class supports loading, caching, - and drawing of Joint Photographic Experts Group (JPEG) File - Interchange Format (JFIF) images. The class supports grayscale - and color (RGB) JPEG image files. -*/ + The Fl_JPEG_Image class supports loading, caching, + and drawing of Joint Photographic Experts Group (JPEG) File + Interchange Format (JFIF) images. The class supports grayscale + and color (RGB) JPEG image files. + */ class FL_EXPORT Fl_JPEG_Image : public Fl_RGB_Image { public: |
