diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2011-01-24 17:04:22 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2011-01-24 17:04:22 +0000 |
| commit | fe25f19767f1cd2393c4d1796fb42d5aa82b194c (patch) | |
| tree | 229437962da4fa67acf27bf171d6124f5631c34e /src/Fl_PNG_Image.cxx | |
| parent | f9363c16d0e6518ba82d05f1f7f415e9224a8e35 (diff) | |
Adding embedded documentation to Fluid if installed odcs are not found. Falls back to the internet if that does not exist either. Also, adds JPEG and PNG images to the Shared Image list if they were loaded from memory - see example use in fluid.cxx which loads and embedded html document containing an embedded PNG image.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8306 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_PNG_Image.cxx')
| -rw-r--r-- | src/Fl_PNG_Image.cxx | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/Fl_PNG_Image.cxx b/src/Fl_PNG_Image.cxx index 6bf39b28c..798c08854 100644 --- a/src/Fl_PNG_Image.cxx +++ b/src/Fl_PNG_Image.cxx @@ -37,6 +37,7 @@ #include <FL/Fl.H> #include <FL/Fl_PNG_Image.H> +#include <FL/Fl_Shared_Image.H> #include <config.h> #include <stdio.h> #include <stdlib.h> @@ -89,11 +90,17 @@ Fl_PNG_Image::Fl_PNG_Image (const char *filename): Fl_RGB_Image(0,0,0) load_png_(filename, NULL, 0); } -/** Constructor that reads a PNG image from memory. +/** + \brief Constructor that reads a PNG image from memory. - \param name_png A name given to this image + Construct an image from a block of memory inside the application. Fluid offers + "binary Data" chunks as a great way to add image data into the C++ source code. + name_png can be NULL. If a name is givem the image is added to the the list of + shared images (see: Fl_Shared_Image) and will be available by that name. + + \param name_png A name given to this image or NULL \param buffer Pointer to the start of the PNG image in memory - \param maxsize Size in bytes of the memory buffer containing the PNG image + \param maxsize Size in bytes of the memory buffer containing the PNG image */ Fl_PNG_Image::Fl_PNG_Image ( const char *name_png, const unsigned char *buffer, int maxsize): Fl_RGB_Image(0,0,0) @@ -111,7 +118,7 @@ void Fl_PNG_Image::load_png_(const char *name_png, const unsigned char *buffer_p png_infop info; // PNG info pointers png_bytep *rows;// PNG row pointers fl_png_memory png_mem_data; - int from_memory = (buffer_png != NULL); // true iff reading image from memory + int from_memory = (buffer_png != NULL); // true if reading image from memory if (!from_memory) { if ((fp = fl_fopen(name_png, "rb")) == NULL) return; @@ -200,7 +207,14 @@ void Fl_PNG_Image::load_png_(const char *name_png, const unsigned char *buffer_p png_read_end(pp, info); png_destroy_read_struct(&pp, &info, NULL); - if (!from_memory) fclose(fp); + if (from_memory) { + if (w() && h() && name_png) { + Fl_Shared_Image *si = new Fl_Shared_Image(name_png, this); + si->add(); + } + } else { + fclose(fp); + } #endif // HAVE_LIBPNG && HAVE_LIBZ } |
