diff options
Diffstat (limited to 'dw')
-rw-r--r-- | dw/fltkimgbuf.cc | 27 | ||||
-rw-r--r-- | dw/fltkimgbuf.hh | 8 | ||||
-rw-r--r-- | dw/fltkplatform.cc | 4 | ||||
-rw-r--r-- | dw/fltkplatform.hh | 3 | ||||
-rw-r--r-- | dw/layout.hh | 5 | ||||
-rw-r--r-- | dw/platform.hh | 12 |
6 files changed, 36 insertions, 23 deletions
diff --git a/dw/fltkimgbuf.cc b/dw/fltkimgbuf.cc index a63a9a89..4b93601f 100644 --- a/dw/fltkimgbuf.cc +++ b/dw/fltkimgbuf.cc @@ -39,19 +39,21 @@ static bool excessiveImageDimensions (int width, int height) width > IMAGE_MAX_AREA / height; } -FltkImgbuf::FltkImgbuf (Type type, int width, int height) +FltkImgbuf::FltkImgbuf (Type type, int width, int height, double gamma) { _MSG("FltkImgbuf: new root %p\n", this); - init (type, width, height, NULL); + init (type, width, height, gamma, NULL); } -FltkImgbuf::FltkImgbuf (Type type, int width, int height, FltkImgbuf *root) +FltkImgbuf::FltkImgbuf (Type type, int width, int height, double gamma, + FltkImgbuf *root) { _MSG("FltkImgbuf: new scaled %p, root is %p\n", this, root); - init (type, width, height, root); + init (type, width, height, gamma, root); } -void FltkImgbuf::init (Type type, int width, int height, FltkImgbuf *root) +void FltkImgbuf::init (Type type, int width, int height, double gamma, + FltkImgbuf *root) { if (excessiveImageDimensions (width, height)) { // Excessive image sizes which would cause crashes due to too @@ -60,7 +62,7 @@ void FltkImgbuf::init (Type type, int width, int height, FltkImgbuf *root) // 1 size. MSG("FltkImgbuf::init: suspicious image size request %d x %d\n", width, height); - init (type, 1, 1, root); + init (type, 1, 1, gamma, root); } else if (width > MAX_WIDTH) { // Too large dimensions cause dangerous overflow errors, so we // limit dimensions to harmless values. @@ -69,15 +71,19 @@ void FltkImgbuf::init (Type type, int width, int height, FltkImgbuf *root) // the negative value -1. MSG("FltkImgbuf::init: cannot handle large width %d\n", width); - init (type, MAX_WIDTH, height, root); + init (type, MAX_WIDTH, height, gamma, root); } else if (height > MAX_HEIGHT) { MSG("FltkImgbuf::init: cannot handle large height %d\n", height); - init (type, width, MAX_HEIGHT, root); + init (type, width, MAX_HEIGHT, gamma, root); + } else if (gamma <= 0) { + MSG("FltkImgbuf::init: non-positive gamma %g\n", gamma); + init (type, width, height, 1, root); } else { this->root = root; this->type = type; this->width = width; this->height = height; + this->gamma = gamma; // TODO: Maybe this is only for root buffers switch (type) { @@ -85,7 +91,8 @@ void FltkImgbuf::init (Type type, int width, int height, FltkImgbuf *root) case RGB: bpp = 3; break; default: bpp = 1; break; } - _MSG("FltkImgbuf::init width=%d height=%d bpp=%d\n", width, height, bpp); + _MSG("FltkImgbuf::init width=%d height=%d bpp=%d gamma=%g\n", + width, height, bpp, gamma); rawdata = new uchar[bpp * width * height]; // Set light-gray as interim background color. memset(rawdata, 222, width*height*bpp); @@ -323,7 +330,7 @@ core::Imgbuf* FltkImgbuf::getScaledBuf (int width, int height) } // This size is not yet used, so a new buffer has to be created. - FltkImgbuf *sb = new FltkImgbuf (type, width, height, this); + FltkImgbuf *sb = new FltkImgbuf (type, width, height, gamma, this); scaledBuffers->append (sb); return sb; } diff --git a/dw/fltkimgbuf.hh b/dw/fltkimgbuf.hh index d862eece..f7455807 100644 --- a/dw/fltkimgbuf.hh +++ b/dw/fltkimgbuf.hh @@ -18,6 +18,7 @@ private: int width, height; Type type; + double gamma; //{ int bpp; @@ -28,8 +29,9 @@ private: // the image buffer. lout::misc::BitSet *copiedRows; - FltkImgbuf (Type type, int width, int height, FltkImgbuf *root); - void init (Type type, int width, int height, FltkImgbuf *root); + FltkImgbuf (Type type, int width, int height, double gamma, + FltkImgbuf *root); + void init (Type type, int width, int height, double gamma, FltkImgbuf *root); int scaledY(int ySrc); int backscaledY(int yScaled); int isRoot() { return (root == NULL); } @@ -39,7 +41,7 @@ protected: ~FltkImgbuf (); public: - FltkImgbuf (Type type, int width, int height); + FltkImgbuf (Type type, int width, int height, double gamma); void setCMap (int *colors, int num_colors); inline void scaleRow (int row, const core::byte *data); diff --git a/dw/fltkplatform.cc b/dw/fltkplatform.cc index 7dd87a18..1d77e289 100644 --- a/dw/fltkplatform.cc +++ b/dw/fltkplatform.cc @@ -704,9 +704,9 @@ void FltkPlatform::copySelection(const char *text) } core::Imgbuf *FltkPlatform::createImgbuf (core::Imgbuf::Type type, - int width, int height) + int width, int height, double gamma) { - return new FltkImgbuf (type, width, height); + return new FltkImgbuf (type, width, height, gamma); } core::ui::ResourceFactory *FltkPlatform::getResourceFactory () diff --git a/dw/fltkplatform.hh b/dw/fltkplatform.hh index 64605b68..2fb95633 100644 --- a/dw/fltkplatform.hh +++ b/dw/fltkplatform.hh @@ -169,7 +169,8 @@ public: core::style::Tooltip *createTooltip (const char *text); void cancelTooltip(); - core::Imgbuf *createImgbuf (core::Imgbuf::Type type, int width, int height); + core::Imgbuf *createImgbuf (core::Imgbuf::Type type, int width, int height, + double gamma); void copySelection(const char *text); diff --git a/dw/layout.hh b/dw/layout.hh index d3ace03a..51d764a4 100644 --- a/dw/layout.hh +++ b/dw/layout.hh @@ -358,9 +358,10 @@ public: return platform->cancelTooltip (); } - inline Imgbuf *createImgbuf (Imgbuf::Type type, int width, int height) + inline Imgbuf *createImgbuf (Imgbuf::Type type, int width, int height, + double gamma) { - return platform->createImgbuf (type, width, height); + return platform->createImgbuf (type, width, height, gamma); } inline void copySelection(const char *text) diff --git a/dw/platform.hh b/dw/platform.hh index 1e16dcfe..532f4cf9 100644 --- a/dw/platform.hh +++ b/dw/platform.hh @@ -146,12 +146,14 @@ public: */ virtual void cancelTooltip () = 0; - /* - * -------------------- - * Image Buffers - * -------------------- + /** + * \brief Create a (platform speficic) image buffer. + * + * "gamma" is the value by which the image data is already + * corrected. */ - virtual Imgbuf *createImgbuf (Imgbuf::Type type, int width, int height) = 0; + virtual Imgbuf *createImgbuf (Imgbuf::Type type, int width, int height, + double gamma) = 0; /** * \brief Copy selected text (0-terminated). |