diff --git a/src/Fl_Shared_Image.cxx b/src/Fl_Shared_Image.cxx index 5e2399f84..20709c3c3 100644 --- a/src/Fl_Shared_Image.cxx +++ b/src/Fl_Shared_Image.cxx @@ -455,9 +455,6 @@ Fl_Shared_Image* Fl_Shared_Image::find(const char *name, int W, int H) { */ Fl_Shared_Image* Fl_Shared_Image::get(const char *name, int W, int H) { Fl_Shared_Image *temp; // Image - - if ((temp = find(name, W, H)) != NULL) return temp; - if ((temp = find(name)) == NULL) { temp = new Fl_Shared_Image(name); @@ -465,15 +462,14 @@ Fl_Shared_Image* Fl_Shared_Image::get(const char *name, int W, int H) { delete temp; return NULL; } - - temp->add(); - } - - if ((temp->w() != W || temp->h() != H) && W && H) { - temp = (Fl_Shared_Image *)temp->copy(W, H); temp->add(); + if (W) temp->scale(W, H, 0, 1); + } else { + Fl_Shared_Image *temp2 = new Fl_Shared_Image(name, temp->image_); + if (W) temp2->scale(W, H, 0, 1); + temp->release(); + temp = temp2; } - return temp; } diff --git a/test/pixmap_browser.cxx b/test/pixmap_browser.cxx index 7f30c8abe..250724122 100644 --- a/test/pixmap_browser.cxx +++ b/test/pixmap_browser.cxx @@ -30,8 +30,10 @@ #include Fl_Box *b; +Fl_Box *small_box; Fl_Double_Window *w; Fl_Shared_Image *img; +Fl_Shared_Image *small_img; static char name[1024]; @@ -39,6 +41,7 @@ static char name[1024]; void load_file(const char *n) { if (img) { ((Fl_Shared_Image*)b->image())->release(); + ((Fl_Shared_Image*)small_box->image())->release(); img = 0L; } if (fl_filename_isdir(n)) { @@ -66,6 +69,11 @@ void load_file(const char *n) { img->scale(b->w(), b->h()); b->label(NULL); b->redraw(); + + small_img = Fl_Shared_Image::get(n/*, small_box->w(), small_box->h()*/); + small_box->image(small_img); + small_img->scale(small_box->w(), small_box->h()); + small_box->redraw(); } void file_cb(const char *n) { @@ -144,6 +152,8 @@ int main(int argc, char **argv) { print.callback(print_cb); Fl_Button svg(190,425,100,25,"save as SVG"); svg.callback(svg_cb); + + small_box = new Fl_Box(10,5, 35, 35); window.show(argc,argv); return Fl::run();