2002-06-29 01:19:42 +04:00
|
|
|
//
|
2002-06-29 04:10:05 +04:00
|
|
|
// "$Id: fl_images_core.cxx,v 1.1.2.2 2002/06/29 00:10:04 matthiaswm Exp $"
|
2002-06-29 01:19:42 +04:00
|
|
|
//
|
|
|
|
// FLTK images library core.
|
|
|
|
//
|
|
|
|
// Copyright 1997-2002 by Easy Software Products.
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
// USA.
|
|
|
|
//
|
|
|
|
// Please report all bugs and problems to "fltk-bugs@fltk.org".
|
|
|
|
//
|
|
|
|
// Contents:
|
|
|
|
//
|
|
|
|
// fl_register_images() - Register the image formats.
|
|
|
|
// fl_check_images() - Check for a supported image format.
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// Include necessary header files...
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <FL/Fl_Shared_Image.H>
|
|
|
|
#include <FL/Fl_JPEG_Image.H>
|
|
|
|
#include <FL/Fl_PNG_Image.H>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "flstring.h"
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Define a simple global image registration function that registers
|
|
|
|
// the extra image formats that aren't part of the core FLTK library.
|
|
|
|
//
|
|
|
|
|
|
|
|
static Fl_Image *fl_check_images(const char *name, uchar *header, int headerlen);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// 'fl_register_images()' - Register the image formats.
|
|
|
|
//
|
|
|
|
|
|
|
|
void fl_register_images() {
|
|
|
|
Fl_Shared_Image::add_handler(fl_check_images);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// 'fl_check_images()' - Check for a supported image format.
|
|
|
|
//
|
|
|
|
|
|
|
|
Fl_Image * // O - Image, if found
|
|
|
|
fl_check_images(const char *name, // I - Filename
|
|
|
|
uchar *header, // I - Header data from file
|
|
|
|
int headerlen) { // I - Amount of data
|
|
|
|
#ifdef HAVE_LIBPNG
|
|
|
|
if (memcmp(header, "\211PNG", 4) == 0) // PNG header
|
|
|
|
return new Fl_PNG_Image(name);
|
2002-06-29 04:10:05 +04:00
|
|
|
#else
|
|
|
|
header = header; name = name; headerlen = headerlen; // avoid warnings
|
2002-06-29 01:19:42 +04:00
|
|
|
#endif // HAVE_LIBPNG
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBJPEG
|
|
|
|
if (memcmp(header, "\377\330\377", 3) == 0 && // Start-of-Image
|
|
|
|
header[3] >= 0xe0 && header[3] <= 0xef)
|
|
|
|
// APPn
|
|
|
|
return new Fl_JPEG_Image(name);
|
2002-06-29 04:10:05 +04:00
|
|
|
#else
|
|
|
|
header = header; name = name; headerlen = headerlen; // avoid warnings
|
2002-06-29 01:19:42 +04:00
|
|
|
#endif // HAVE_LIBJPEG
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
2002-06-29 04:10:05 +04:00
|
|
|
// End of "$Id: fl_images_core.cxx,v 1.1.2.2 2002/06/29 00:10:04 matthiaswm Exp $".
|
2002-06-29 01:19:42 +04:00
|
|
|
//
|