|
fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation) ![]() |
00001 // 00002 // "$Id: fl_images_core.cxx 7903 2010-11-28 21:06:39Z matt $" 00003 // 00004 // FLTK images library core. 00005 // 00006 // Copyright 1997-2010 by Easy Software Products. 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Library General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Library General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00021 // USA. 00022 // 00023 // Please report all bugs and problems on the following page: 00024 // 00025 // http://www.fltk.org/str.php 00026 // 00027 // Contents: 00028 // 00029 // fl_register_images() - Register the image formats. 00030 // fl_check_images() - Check for a supported image format. 00031 // 00032 00033 // 00034 // Include necessary header files... 00035 // 00036 00037 #include <FL/Fl_Shared_Image.H> 00038 #include <FL/Fl_BMP_Image.H> 00039 #include <FL/Fl_GIF_Image.H> 00040 #include <FL/Fl_JPEG_Image.H> 00041 #include <FL/Fl_PNG_Image.H> 00042 #include <FL/Fl_PNM_Image.H> 00043 #include <stdio.h> 00044 #include <stdlib.h> 00045 #include "flstring.h" 00046 00047 00048 // 00049 // Define a simple global image registration function that registers 00050 // the extra image formats that aren't part of the core FLTK library. 00051 // 00052 00053 static Fl_Image *fl_check_images(const char *name, uchar *header, int headerlen); 00054 00055 00063 void fl_register_images() { 00064 Fl_Shared_Image::add_handler(fl_check_images); 00065 } 00066 00067 00068 // 00069 // 'fl_check_images()' - Check for a supported image format. 00070 // 00071 00072 Fl_Image * // O - Image, if found 00073 fl_check_images(const char *name, // I - Filename 00074 uchar *header, // I - Header data from file 00075 int) { // I - Amount of data (not used) 00076 if (memcmp(header, "GIF87a", 6) == 0 || 00077 memcmp(header, "GIF89a", 6) == 0) // GIF file 00078 return new Fl_GIF_Image(name); 00079 00080 if (memcmp(header, "BM", 2) == 0) // BMP file 00081 return new Fl_BMP_Image(name); 00082 00083 if (header[0] == 'P' && header[1] >= '1' && header[1] <= '7') 00084 // Portable anymap 00085 return new Fl_PNM_Image(name); 00086 00087 #ifdef HAVE_LIBPNG 00088 if (memcmp(header, "\211PNG", 4) == 0)// PNG file 00089 return new Fl_PNG_Image(name); 00090 #endif // HAVE_LIBPNG 00091 00092 #ifdef HAVE_LIBJPEG 00093 if (memcmp(header, "\377\330\377", 3) == 0 && 00094 // Start-of-Image 00095 header[3] >= 0xc0 && header[3] <= 0xef) 00096 // APPn for JPEG file 00097 return new Fl_JPEG_Image(name); 00098 #endif // HAVE_LIBJPEG 00099 00100 return 0; 00101 } 00102 00103 00104 // 00105 // End of "$Id: fl_images_core.cxx 7903 2010-11-28 21:06:39Z matt $". 00106 //