From f79c2375da765077fd6cbd9fbaf9fe20bcbf5a55 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Sat, 25 May 2002 02:56:59 +0000 Subject: Tag image data as allocated so that we don't waste memory. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2257 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CHANGES | 3 ++- src/Fl_BMP_Image.cxx | 5 +++-- src/Fl_JPEG_Image.cxx | 5 +++-- src/Fl_PNG_Image.cxx | 5 +++-- src/Fl_Shared_Image.cxx | 12 +++++++++--- src/Fl_XPM_Image.cxx | 6 ++++-- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/CHANGES b/CHANGES index 6dfa5f858..5385da192 100644 --- a/CHANGES +++ b/CHANGES @@ -1,7 +1,8 @@ CHANGES IN FLTK 1.1.0rc3 - Documentation updates. - - Fl_Shared_Image didn't delete images that were loaded. + - Fl_BMP_Image, Fl_JPEG_Image, Fl_PNG_Image, and Fl_Shared_Image + didn't delete image data that was allocated. - Enabled the OpenGL and threads demos when compiling for MingW. - Fl_File_Input didn't update the directory buttons if a diff --git a/src/Fl_BMP_Image.cxx b/src/Fl_BMP_Image.cxx index 4a911e56c..dbc6841f0 100644 --- a/src/Fl_BMP_Image.cxx +++ b/src/Fl_BMP_Image.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_BMP_Image.cxx,v 1.1.2.3 2002/05/24 14:19:19 easysw Exp $" +// "$Id: Fl_BMP_Image.cxx,v 1.1.2.4 2002/05/25 02:56:59 easysw Exp $" // // Fl_BMP_Image routines. // @@ -140,6 +140,7 @@ Fl_BMP_Image::Fl_BMP_Image(const char *bmp) // I - File to read fseek(fp, offbits, SEEK_SET); array = new uchar[w() * h() * d()]; + alloc_array = 1; // Read the image data... color = 0; @@ -370,5 +371,5 @@ read_long(FILE *fp) { // I - File to read from // -// End of "$Id: Fl_BMP_Image.cxx,v 1.1.2.3 2002/05/24 14:19:19 easysw Exp $". +// End of "$Id: Fl_BMP_Image.cxx,v 1.1.2.4 2002/05/25 02:56:59 easysw Exp $". // diff --git a/src/Fl_JPEG_Image.cxx b/src/Fl_JPEG_Image.cxx index 34bbc8878..183c41eba 100644 --- a/src/Fl_JPEG_Image.cxx +++ b/src/Fl_JPEG_Image.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_JPEG_Image.cxx,v 1.1.2.4 2002/01/15 01:33:16 easysw Exp $" +// "$Id: Fl_JPEG_Image.cxx,v 1.1.2.5 2002/05/25 02:56:59 easysw Exp $" // // Fl_JPEG_Image routines. // @@ -76,6 +76,7 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *jpeg) // I - File to load d(cinfo.output_components); array = new uchar[w() * h() * d()]; + alloc_array = 1; jpeg_start_decompress(&cinfo); @@ -95,5 +96,5 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *jpeg) // I - File to load } // -// End of "$Id: Fl_JPEG_Image.cxx,v 1.1.2.4 2002/01/15 01:33:16 easysw Exp $". +// End of "$Id: Fl_JPEG_Image.cxx,v 1.1.2.5 2002/05/25 02:56:59 easysw Exp $". // diff --git a/src/Fl_PNG_Image.cxx b/src/Fl_PNG_Image.cxx index 9e14bd62a..01de9f705 100644 --- a/src/Fl_PNG_Image.cxx +++ b/src/Fl_PNG_Image.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_PNG_Image.cxx,v 1.1.2.6 2002/05/24 14:19:19 easysw Exp $" +// "$Id: Fl_PNG_Image.cxx,v 1.1.2.7 2002/05/25 02:56:59 easysw Exp $" // // Fl_PNG_Image routines. // @@ -108,6 +108,7 @@ Fl_PNG_Image::Fl_PNG_Image(const char *png) // I - File to read # endif // HAVE_PNG_GET_VALID && HAVE_SET_TRNS_TO_ALPHA array = new uchar[w() * h() * d()]; + alloc_array = 1; // Allocate pointers... rows = new png_bytep[h()]; @@ -135,5 +136,5 @@ Fl_PNG_Image::Fl_PNG_Image(const char *png) // I - File to read // -// End of "$Id: Fl_PNG_Image.cxx,v 1.1.2.6 2002/05/24 14:19:19 easysw Exp $". +// End of "$Id: Fl_PNG_Image.cxx,v 1.1.2.7 2002/05/25 02:56:59 easysw Exp $". // diff --git a/src/Fl_Shared_Image.cxx b/src/Fl_Shared_Image.cxx index db73a295c..3b2e874a2 100644 --- a/src/Fl_Shared_Image.cxx +++ b/src/Fl_Shared_Image.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Shared_Image.cxx,v 1.23.2.10 2002/05/25 02:27:20 easysw Exp $" +// "$Id: Fl_Shared_Image.cxx,v 1.23.2.11 2002/05/25 02:56:59 easysw Exp $" // // Shared image code for the Fast Light Tool Kit (FLTK). // @@ -275,6 +275,12 @@ Fl_Shared_Image::copy(int W, int H) { Fl_Image *temp_image; // New image file Fl_Shared_Image *temp_shared; // New shared image + // See if the new and old sizes are the same... + if (image_ && image_->w() == W && image_->h() == H) { + refcount_ ++; + return (this); + } + // Make a copy of the image we're sharing... if (!image_) temp_image = 0; else temp_image = image_->copy(W, H); @@ -287,7 +293,7 @@ Fl_Shared_Image::copy(int W, int H) { temp_shared->refcount_ = 1; temp_shared->image_ = temp_image; - temp_shared->alloc_image_ = 0; + temp_shared->alloc_image_ = 1; temp_shared->update(); @@ -455,5 +461,5 @@ Fl_Shared_Image::remove_handler(Fl_Shared_Handler *f) { // -// End of "$Id: Fl_Shared_Image.cxx,v 1.23.2.10 2002/05/25 02:27:20 easysw Exp $". +// End of "$Id: Fl_Shared_Image.cxx,v 1.23.2.11 2002/05/25 02:56:59 easysw Exp $". // diff --git a/src/Fl_XPM_Image.cxx b/src/Fl_XPM_Image.cxx index a28a34066..7b2e7bbb2 100644 --- a/src/Fl_XPM_Image.cxx +++ b/src/Fl_XPM_Image.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_XPM_Image.cxx,v 1.1.2.4 2002/04/11 11:52:42 easysw Exp $" +// "$Id: Fl_XPM_Image.cxx,v 1.1.2.5 2002/05/25 02:56:59 easysw Exp $" // // Fl_XPM_Image routines. // @@ -120,10 +120,12 @@ Fl_XPM_Image::Fl_XPM_Image(const char *name) : Fl_Pixmap((char *const*)0) { fclose(f); data((const char **)new_data, i); + alloc_data = 1; + measure(); } // -// End of "$Id: Fl_XPM_Image.cxx,v 1.1.2.4 2002/04/11 11:52:42 easysw Exp $". +// End of "$Id: Fl_XPM_Image.cxx,v 1.1.2.5 2002/05/25 02:56:59 easysw Exp $". // -- cgit v1.2.3