diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2014-10-14 11:53:51 +0000 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2014-10-14 11:53:51 +0000 |
| commit | d24a6b2633664959d0b0ab5fd1ab3aa140ab877f (patch) | |
| tree | 91f87cbc88b4909cee27ba1c6644d6cd278d2df1 /src/Fl_Image.cxx | |
| parent | f1bf759c646501707def7a27bc2ca76c30947ba4 (diff) | |
Move RGB image scaling algorithm methods in base class Fl_Image.
See also discussion in fltk.coredev of Sept 07, 2014 and later
with subject "Fixing the nearest-neighbour scaling".
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10377 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Image.cxx')
| -rw-r--r-- | src/Fl_Image.cxx | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx index 71e117799..73eec41b8 100644 --- a/src/Fl_Image.cxx +++ b/src/Fl_Image.cxx @@ -3,7 +3,7 @@ // // Image drawing code for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2012 by Bill Spitzak and others. +// Copyright 1998-2014 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,6 +34,8 @@ void fl_restore_clip(); // from fl_rect.cxx // Base image class... // +Fl_RGB_Scaling Fl_Image::RGB_scaling_ = FL_RGB_SCALING_NEAREST; + /** The destructor is a virtual method that frees all memory used by the image. @@ -159,12 +161,23 @@ Fl_Image::measure(const Fl_Label *lo, // I - Label lh = img->h(); } +/** Sets the RGB image scaling method used for copy(int, int). + Applies to all RGB images, defaults to FL_RGB_SCALING_NEAREST. +*/ +void Fl_Image::RGB_scaling(Fl_RGB_Scaling method) { + RGB_scaling_ = method; +} + +/** Returns the currently used RGB image scaling method. */ +Fl_RGB_Scaling Fl_Image::RGB_scaling() { + return RGB_scaling_; +} + // // RGB image class... // size_t Fl_RGB_Image::max_size_ = ~((size_t)0); -Fl_RGB_Scaling Fl_RGB_Image::scaling_ = FL_SCALING_NEAREST; int fl_convert_pixmap(const char*const* cdata, uchar* out, Fl_Color bg); @@ -261,7 +274,7 @@ Fl_Image *Fl_RGB_Image::copy(int W, int H) { new_image = new Fl_RGB_Image(new_array, W, H, d()); new_image->alloc_array = 1; - if (scaling_ == FL_SCALING_NEAREST) { + if (Fl_Image::RGB_scaling() == FL_RGB_SCALING_NEAREST) { // Scale the image using a nearest-neighbor algorithm... for (dy = H, sy = 0, yerr = H, new_ptr = new_array; dy > 0; dy --) { for (dx = W, xerr = W, old_ptr = array + sy * line_d; dx > 0; dx --) { @@ -284,7 +297,7 @@ Fl_Image *Fl_RGB_Image::copy(int W, int H) { } } } else { - // Bilinear scaling + // Bilinear scaling (FL_RGB_SCALING_BILINEAR) const float xscale = (w() - 1) / (float) W; const float yscale = (h() - 1) / (float) H; for (dy = 0; dy < H; dy++) { @@ -679,14 +692,6 @@ void Fl_RGB_Image::label(Fl_Menu_Item* m) { m->label(_FL_IMAGE_LABEL, (const char*)this); } -void Fl_RGB_Image::scaling(Fl_RGB_Scaling method) { - scaling_ = method; -} - -Fl_RGB_Scaling Fl_RGB_Image::scaling() { - return scaling_; -} - // // End of "$Id$". // |
