summaryrefslogtreecommitdiff
path: root/src/Fl_Image.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Fl_Image.cxx')
-rw-r--r--src/Fl_Image.cxx78
1 files changed, 48 insertions, 30 deletions
diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx
index 25c3f0afe..7c3233c89 100644
--- a/src/Fl_Image.cxx
+++ b/src/Fl_Image.cxx
@@ -233,24 +233,39 @@ int fl_convert_pixmap(const char*const* cdata, uchar* out, Fl_Color bg);
/**
- 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.
-
- This constructor sets Fl_RGB_Image::alloc_array to 0.
- To have the image object control the deallocation of the data array,
- set alloc_array to non-zero after construction.
- \see Fl_Image::data(), Fl_Image::w(), Fl_Image::h(), Fl_Image::d(), Fl_Image::ld()
- */
+ The constructor creates a new image from the specified data.
+
+ The data array \p bits must contain sufficient data to provide
+ \p W * \p H * \p D image bytes and optional line padding, see \p LD.
+
+ \p W and \p H are the width and height of the image in pixels, resp.
+
+ \p D is the image depth and can be:
+ - D=1: each uchar in \p bits[] is a grayscale pixel value
+ - D=2: each uchar pair in \p bits[] is a grayscale + alpha pixel value
+ - D=3: each uchar triplet in \p bits[] is an R/G/B pixel value
+ - D=4: each uchar quad in \p bits[] is an R/G/B/A pixel value
+
+ \p LD specifies the line data size of the array, see Fl_Image::ld(int).
+ If \p LD is zero, then \p W * \p D is assumed, otherwise \p LD must be
+ greater than or equal to \p W * \p D to account for (unused) extra data
+ per line (padding).
+
+ The caller is responsible that the image data array \p bits persists as
+ long as the image is used.
+
+ This constructor sets Fl_RGB_Image::alloc_array to 0.
+ To have the image object control the deallocation of the data array
+ \p bits, set alloc_array to non-zero after construction.
+
+ \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).
+ \param[in] LD Line data size (default=0).
+
+ \see Fl_Image::data(), Fl_Image::w(), Fl_Image::h(), Fl_Image::d(), Fl_Image::ld(int)
+*/
Fl_RGB_Image::Fl_RGB_Image(const uchar *bits, int W, int H, int D, int LD) :
Fl_Image(W,H,D),
array(bits),
@@ -264,12 +279,15 @@ Fl_RGB_Image::Fl_RGB_Image(const uchar *bits, int W, int H, int D, int LD) :
/**
- The constructor creates a new RGBA image from the specified Fl_Pixmap.
-
- The RGBA image is built fully opaque except for the transparent area
- of the pixmap that is assigned the \p bg color with full transparency.
- This constructor sets Fl_RGB_Image::alloc_array to 1.
- */
+ The constructor creates a new RGBA image from the specified Fl_Pixmap.
+
+ The RGBA image is built fully opaque except for the transparent area
+ of the pixmap that is assigned the \p bg color with full transparency.
+
+ This constructor creates a new internal data array and sets
+ Fl_RGB_Image::alloc_array to 1 so the data array is deleted when the
+ image is destroyed.
+*/
Fl_RGB_Image::Fl_RGB_Image(const Fl_Pixmap *pxm, Fl_Color bg):
Fl_Image(pxm->w(), pxm->h(), 4),
id_(0),
@@ -282,10 +300,10 @@ Fl_RGB_Image::Fl_RGB_Image(const Fl_Pixmap *pxm, Fl_Color bg):
}
-/**
- The destructor frees all memory and server resources that are used by
- the image.
- */
+/**
+ The destructor frees all memory and server resources that are used by
+ the image.
+*/
Fl_RGB_Image::~Fl_RGB_Image() {
uncache();
if (alloc_array) delete[] (uchar *)array;
@@ -383,7 +401,7 @@ Fl_Image *Fl_RGB_Image::copy(int W, int H) {
for (dy = 0; dy < H; dy++) {
float oldy = dy * yscale;
if (oldy >= h())
- oldy = (float)(h() - 1);
+ oldy = float(h() - 1);
const float yfract = oldy - (unsigned) oldy;
for (dx = 0; dx < W; dx++) {
@@ -391,7 +409,7 @@ Fl_Image *Fl_RGB_Image::copy(int W, int H) {
float oldx = dx * xscale;
if (oldx >= w())
- oldx = (float)(w() - 1);
+ oldx = float(w() - 1);
const float xfract = oldx - (unsigned) oldx;
const unsigned leftx = (unsigned)oldx;