From 1acc39c5d8d5b3db88abfd008699dadb8aade2b9 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Mon, 19 Nov 2001 01:06:45 +0000 Subject: OK, lots of changes to the Fl_Image, Fl_Bitmap, Fl_Pixmap, and Fl_RGB_Image classes: new copy(), copy(w,h), desaturate(), color_average(), and inactive() methods, alloc_xyz member for copied data, etc. Updated test programs to use inactive() and copy() methods to create inactive images for the test buttons, plus the inactive button to toggle it... Added start of separate image classes, a la 2.0, for various image formats. FLUID will also be updated for it... git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1703 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_JPEG_Image.cxx | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 src/Fl_JPEG_Image.cxx (limited to 'src/Fl_JPEG_Image.cxx') diff --git a/src/Fl_JPEG_Image.cxx b/src/Fl_JPEG_Image.cxx new file mode 100644 index 000000000..0c38b4709 --- /dev/null +++ b/src/Fl_JPEG_Image.cxx @@ -0,0 +1,126 @@ +// +// "$Id: Fl_JPEG_Image.cxx,v 1.1.2.1 2001/11/19 01:06:45 easysw Exp $" +// +// Fl_JPEG_Image routines. +// +// Copyright 1997-2001 by Easy Software Products. +// Image support donated by Matthias Melcher, Copyright 2000. +// +// 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: +// +// + +// +// Include necessary header files... +// + +#include +#include "config.h" +#include +#include +#include +#include +#ifdef HAVE_STRINGS_H +# include +#endif /* HAVE_STRINGS_H */ +#include + +#if defined(WIN32) && ! defined(__CYGWIN__) +# include +# include +# define strcasecmp(s,t) stricmp((s), (t)) +# define strncasecmp(s,t,n) strnicmp((s), (t), (n)) +#elif defined(__EMX__) +# define strcasecmp(s,t) stricmp((s), (t)) +# define strncasecmp(s,t,n) strnicmp((s), (t), (n)) +#else +# include +#endif // WIN32 + +extern "C" +{ +#ifdef HAVE_LIBJPEG +# include +#endif // HAVE_LIBJPEG +} + +#define MAX_COLUMNS 200 + + +#if 0 +#ifdef HAVE_LIBJPEG +// +// 'Fl_Help_View::load_jpeg()' - Load a JPEG image file. +// + +int // O - 0 = success, -1 = fail +Fl_Help_View::load_jpeg(Fl_Help_Image *img, // I - Image pointer + FILE *fp) // I - File to load from +{ + struct jpeg_decompress_struct cinfo; // Decompressor info + struct jpeg_error_mgr jerr; // Error handler info + JSAMPROW row; // Sample row pointer + + + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_decompress(&cinfo); + jpeg_stdio_src(&cinfo, fp); + jpeg_read_header(&cinfo, 1); + + cinfo.quantize_colors = 0; + cinfo.out_color_space = JCS_RGB; + cinfo.out_color_components = 3; + cinfo.output_components = 3; + + jpeg_calc_output_dimensions(&cinfo); + + img->w = cinfo.output_width; + img->h = cinfo.output_height; + img->d = cinfo.output_components; + img->data = (unsigned char *)malloc(img->w * img->h * img->d); + + if (img->data == NULL) + { + jpeg_destroy_decompress(&cinfo); + return (0); + } + + jpeg_start_decompress(&cinfo); + + while (cinfo.output_scanline < cinfo.output_height) + { + row = (JSAMPROW)(img->data + + cinfo.output_scanline * cinfo.output_width * + cinfo.output_components); + jpeg_read_scanlines(&cinfo, &row, (JDIMENSION)1); + } + + jpeg_finish_decompress(&cinfo); + jpeg_destroy_decompress(&cinfo); + + return (1); +} +#endif // HAVE_LIBJPEG + +#endif // 0 + +// +// End of "$Id: Fl_JPEG_Image.cxx,v 1.1.2.1 2001/11/19 01:06:45 easysw Exp $". +// -- cgit v1.2.3