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
This commit is contained in:
Michael R Sweet 2002-05-25 02:56:59 +00:00
parent 30b57935f9
commit f79c2375da
6 changed files with 24 additions and 12 deletions

View File

@ -1,7 +1,8 @@
CHANGES IN FLTK 1.1.0rc3 CHANGES IN FLTK 1.1.0rc3
- Documentation updates. - 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 - Enabled the OpenGL and threads demos when compiling
for MingW. for MingW.
- Fl_File_Input didn't update the directory buttons if a - Fl_File_Input didn't update the directory buttons if a

View File

@ -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. // 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); fseek(fp, offbits, SEEK_SET);
array = new uchar[w() * h() * d()]; array = new uchar[w() * h() * d()];
alloc_array = 1;
// Read the image data... // Read the image data...
color = 0; 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 $".
// //

View File

@ -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. // 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); d(cinfo.output_components);
array = new uchar[w() * h() * d()]; array = new uchar[w() * h() * d()];
alloc_array = 1;
jpeg_start_decompress(&cinfo); 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 $".
// //

View File

@ -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. // 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 # endif // HAVE_PNG_GET_VALID && HAVE_SET_TRNS_TO_ALPHA
array = new uchar[w() * h() * d()]; array = new uchar[w() * h() * d()];
alloc_array = 1;
// Allocate pointers... // Allocate pointers...
rows = new png_bytep[h()]; 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 $".
// //

View File

@ -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). // 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_Image *temp_image; // New image file
Fl_Shared_Image *temp_shared; // New shared image 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... // Make a copy of the image we're sharing...
if (!image_) temp_image = 0; if (!image_) temp_image = 0;
else temp_image = image_->copy(W, H); 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->refcount_ = 1;
temp_shared->image_ = temp_image; temp_shared->image_ = temp_image;
temp_shared->alloc_image_ = 0; temp_shared->alloc_image_ = 1;
temp_shared->update(); 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 $".
// //

View File

@ -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. // Fl_XPM_Image routines.
// //
@ -120,10 +120,12 @@ Fl_XPM_Image::Fl_XPM_Image(const char *name) : Fl_Pixmap((char *const*)0) {
fclose(f); fclose(f);
data((const char **)new_data, i); data((const char **)new_data, i);
alloc_data = 1;
measure(); 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 $".
// //