FLTK logo

[master] e698af0 - Fix issue #427 - 2nd part

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] e698af0 - Fix issue #427 - 2nd part "ManoloFLTK" Jun 20, 2022  
 
commit e698af035a8d9363ac6d212a8e986e1f4fdac969
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Mon Jun 20 12:49:38 2022 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Mon Jun 20 12:49:38 2022 +0200

    Fix issue #427 - 2nd part
    
    Fix Fl_Tiled_Image made from scaled source image.
    Fix Fl_Shared_Image::update() to allow scaled source image.
    Correct handling of default value (-1) of 3rd argument of 3-argument Fl_BMP_Image constructor.

 src/Fl_BMP_Image.cxx    | 3 ++-
 src/Fl_Shared_Image.cxx | 6 ++++--
 src/Fl_Tiled_Image.cxx  | 8 ++++++--
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git src/Fl_BMP_Image.cxx src/Fl_BMP_Image.cxx
index 8b326ed..de444f9 100644
--- src/Fl_BMP_Image.cxx
+++ src/Fl_BMP_Image.cxx
@@ -103,7 +103,8 @@ Fl_BMP_Image::Fl_BMP_Image(const char *imagename, const unsigned char *data, con
 : Fl_RGB_Image(0,0,0)
 {
   Fl_Image_Reader rdr;
-  if (rdr.open(imagename, data, length) == -1) {
+  int retval = (length < 0 ? rdr.open(imagename, data) : rdr.open(imagename, data, (size_t)length));
+  if (retval == -1) {
     ld(ERR_FILE_ACCESS);
   } else {
     load_bmp_(rdr);
diff --git src/Fl_Shared_Image.cxx src/Fl_Shared_Image.cxx
index 91e093b..6c14b9c 100644
--- src/Fl_Shared_Image.cxx
+++ src/Fl_Shared_Image.cxx
@@ -190,10 +190,12 @@ Fl_Shared_Image::add() {
 void
 Fl_Shared_Image::update() {
   if (image_) {
-    w(image_->w());
-    h(image_->h());
+    int W = w(), H = h();
+    w(image_->data_w());
+    h(image_->data_h());
     d(image_->d());
     data(image_->data(), image_->count());
+    if (W && H) scale(W, H, 0, 1);
   }
 }
 
diff --git src/Fl_Tiled_Image.cxx src/Fl_Tiled_Image.cxx
index da1ed55..2ec62e7 100644
--- src/Fl_Tiled_Image.cxx
+++ src/Fl_Tiled_Image.cxx
@@ -92,7 +92,9 @@ void
 Fl_Tiled_Image::color_average(Fl_Color c,       // I - Color to blend with
                               float    i) {     // I - Blend fraction
   if (!alloc_image_) {
-    image_       = image_->copy();
+    int W = image_->w(), H = image_->h();
+    image_       = image_->copy(image_->data_w(), image_->data_h());
+    image_->scale(W, H, 0, 1);
     alloc_image_ = 1;
   }
 
@@ -107,7 +109,9 @@ Fl_Tiled_Image::color_average(Fl_Color c,       // I - Color to blend with
 void
 Fl_Tiled_Image::desaturate() {
   if (!alloc_image_) {
-    image_       = image_->copy();
+    int W = image_->w(), H = image_->h();
+    image_       = image_->copy(image_->data_w(), image_->data_h());
+    image_->scale(W, H, 0, 1);
     alloc_image_ = 1;
   }
 
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.