summaryrefslogtreecommitdiff
path: root/src/Fl_JPEG_Image.cxx
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2001-11-23 12:06:36 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2001-11-23 12:06:36 +0000
commit4087b8cd9a139664420468c57489cae73c8b830a (patch)
treee760b9aed14a687ec0e1217676adf43cfe16d889 /src/Fl_JPEG_Image.cxx
parentf5258404959cff3a299c796676b553b843a94355 (diff)
Add code for PNG and JPEG images.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1713 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_JPEG_Image.cxx')
-rw-r--r--src/Fl_JPEG_Image.cxx61
1 files changed, 17 insertions, 44 deletions
diff --git a/src/Fl_JPEG_Image.cxx b/src/Fl_JPEG_Image.cxx
index 0c38b4709..73df5f24b 100644
--- a/src/Fl_JPEG_Image.cxx
+++ b/src/Fl_JPEG_Image.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_JPEG_Image.cxx,v 1.1.2.1 2001/11/19 01:06:45 easysw Exp $"
+// "$Id: Fl_JPEG_Image.cxx,v 1.1.2.2 2001/11/23 12:06:36 easysw Exp $"
//
// Fl_JPEG_Image routines.
//
@@ -32,27 +32,9 @@
//
#include <FL/Fl_JPEG_Image.H>
-#include "config.h"
+#include <config.h>
#include <stdio.h>
#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#ifdef HAVE_STRINGS_H
-# include <strings.h>
-#endif /* HAVE_STRINGS_H */
-#include <errno.h>
-
-#if defined(WIN32) && ! defined(__CYGWIN__)
-# include <io.h>
-# include <direct.h>
-# 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 <unistd.h>
-#endif // WIN32
extern "C"
{
@@ -61,24 +43,22 @@ extern "C"
#endif // HAVE_LIBJPEG
}
-#define MAX_COLUMNS 200
-
-#if 0
-#ifdef HAVE_LIBJPEG
//
-// 'Fl_Help_View::load_jpeg()' - Load a JPEG image file.
+// 'Fl_JPEG_Image::Fl_JPEG_Image()' - 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
-{
+Fl_JPEG_Image::Fl_JPEG_Image(const char *jpeg) // I - File to load
+ : Fl_RGB_Image(0,0,0) {
+#ifdef HAVE_LIBJPEG
+ FILE *fp; // File pointer
struct jpeg_decompress_struct cinfo; // Decompressor info
struct jpeg_error_mgr jerr; // Error handler info
JSAMPROW row; // Sample row pointer
+ if ((fp = fopen(jpeg, "rb")) == NULL) return;
+
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo, fp);
@@ -91,22 +71,17 @@ Fl_Help_View::load_jpeg(Fl_Help_Image *img, // I - Image pointer
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);
+ w(cinfo.output_width);
+ h(cinfo.output_height);
+ d(cinfo.output_components);
- if (img->data == NULL)
- {
- jpeg_destroy_decompress(&cinfo);
- return (0);
- }
+ array = new uchar[w() * h() * d()];
jpeg_start_decompress(&cinfo);
while (cinfo.output_scanline < cinfo.output_height)
{
- row = (JSAMPROW)(img->data +
+ row = (JSAMPROW)(array +
cinfo.output_scanline * cinfo.output_width *
cinfo.output_components);
jpeg_read_scanlines(&cinfo, &row, (JDIMENSION)1);
@@ -115,12 +90,10 @@ Fl_Help_View::load_jpeg(Fl_Help_Image *img, // I - Image pointer
jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
- return (1);
-}
+ fclose(fp);
#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 $".
+// End of "$Id: Fl_JPEG_Image.cxx,v 1.1.2.2 2001/11/23 12:06:36 easysw Exp $".
//