kopia lustrzana https://github.com/jamescoxon/dl-fldigi
Remove JPEG write support
Also make libpng a hard dependency and remove USE_LIBPNG conditionalspull/2/head
rodzic
44eceae21e
commit
974e1ec9ef
2
INSTALL
2
INSTALL
|
@ -13,7 +13,7 @@ To compile fldigi you will need:
|
|||
|
||||
* The samplerate (a.k.a. secret rabbit code) library.
|
||||
|
||||
* The Independent JPEG Group's JPEG library, or the PNG library.
|
||||
* The PNG library.
|
||||
|
||||
You should also install the libraries and headers for PortAudio, the
|
||||
Portable audio I/O library.
|
||||
|
|
27
configure.ac
27
configure.ac
|
@ -152,24 +152,6 @@ AC_FLDIGI_BIND
|
|||
# Set HAVE_FLUID Makefile conditional
|
||||
AC_FLDIGI_FLTK
|
||||
|
||||
### Image libraries
|
||||
# JPEG:
|
||||
# Test if we can compile a program that includes jpeglib.h
|
||||
# and link it either using the FLTK flags set above, or
|
||||
# with -ljpeg.
|
||||
# Set ac_cv_libjpeg to yes/no
|
||||
# Define LIBJPEG_CFLAGS and LIBJPEG_CFLAGS and add them to
|
||||
# IMAGE_CFLAGS and IMAGE_LIBS.
|
||||
# Define USE_LIBJPEG in config.h
|
||||
# PNG:
|
||||
# Check with the AC_FLDIGI_PKG_CHECK macro
|
||||
# Set ac_cv_libpng to yes/no
|
||||
# Define LIBJPEG_CFLAGS and LIBJPEG_CFLAGS and add them to
|
||||
# IMAGE_CFLAGS and IMAGE_LIBS.
|
||||
# Define USE_LIBPNG in config.h
|
||||
# Substitute IMAGE_CFLAGS and IMAGE_LIBS in Makefile
|
||||
AC_FLDIGI_IMAGES
|
||||
|
||||
### XML-RPC library
|
||||
# Set ac_cv_xmlrpc to yes/no
|
||||
# Substitute XMLRPC_CFLAGS and XMLRPC_LIBS in Makefile
|
||||
|
@ -182,6 +164,12 @@ AC_FLDIGI_XMLRPC
|
|||
# Define USE_OSS in config.h
|
||||
AC_FLDIGI_OSS
|
||||
|
||||
### libpng
|
||||
# Set ac_cv_png to yes/no (not used because we require libpng)
|
||||
# Define USE_PNG in config.h (as above)
|
||||
# Substitute PNG_CFLAGS and PNG_LIBS in Makefile
|
||||
AC_FLDIGI_PKG_CHECK([png], [libpng >= 1.2.8], [no], [no])
|
||||
|
||||
### libsamplerate
|
||||
# Set ac_cv_samplerate to yes/no (not used because we require samplerate)
|
||||
# Define USE_SAMPLERATE in config.h (as above)
|
||||
|
@ -267,9 +255,6 @@ Configuration summary:
|
|||
CPU optimizations ........... $ac_cv_opt
|
||||
Debugging ................... $ac_cv_debug
|
||||
|
||||
png ......................... $ac_cv_libpng
|
||||
jpeg ........................ $ac_cv_libjpeg
|
||||
|
||||
sndfile ..................... $ac_cv_sndfile
|
||||
oss ......................... $ac_cv_oss
|
||||
portaudio ................... $ac_cv_portaudio
|
||||
|
|
|
@ -9,7 +9,7 @@ AC_DEFUN([AC_FLDIGI_BUILD_INFO], [
|
|||
AC_SUBST([BUILD_CPPFLAGS])
|
||||
|
||||
BUILD_CXXFLAGS="$PORTAUDIO_CFLAGS $FLTK_CFLAGS $SNDFILE_CFLAGS $SAMPLERATE_CFLAGS \
|
||||
$PULSEAUDIO_CFLAGS $HAMLIB_CFLAGS $IMAGE_CFLAGS $XMLRPC_CFLAGS $MAC_UNIVERSAL_CFLAGS \
|
||||
$PULSEAUDIO_CFLAGS $HAMLIB_CFLAGS $PNG_CFLAGS $XMLRPC_CFLAGS $MAC_UNIVERSAL_CFLAGS \
|
||||
$INTL_CFLAGS $PTW32_CFLAGS $BFD_CFLAGS -pipe -Wall -fexceptions $OPT_CFLAGS $DEBUG_CFLAGS"
|
||||
BUILD_LDFLAGS="$MAC_UNIVERSAL_LDFLAGS"
|
||||
if test "x$ac_cv_debug" = "xyes"; then
|
||||
|
@ -22,7 +22,7 @@ $INTL_CFLAGS $PTW32_CFLAGS $BFD_CFLAGS -pipe -Wall -fexceptions $OPT_CFLAGS $DEB
|
|||
AC_SUBST([BUILD_LDFLAGS])
|
||||
|
||||
BUILD_LDADD="$PORTAUDIO_LIBS $BOOST_LDFLAGS $FLTK_LIBS $SNDFILE_LIBS $SAMPLERATE_LIBS \
|
||||
$PULSEAUDIO_LIBS $HAMLIB_LIBS $IMAGE_LIBS $XMLRPC_LIBS $INTL_LIBS $PTW32_LIBS $BFD_LIBS $EXTRA_LIBS"
|
||||
$PULSEAUDIO_LIBS $HAMLIB_LIBS $PNG_LIBS $XMLRPC_LIBS $INTL_LIBS $PTW32_LIBS $BFD_LIBS $EXTRA_LIBS"
|
||||
AC_SUBST([BUILD_LDADD])
|
||||
|
||||
#define build variables for config.h
|
||||
|
|
150
m4/images.m4
150
m4/images.m4
|
@ -1,150 +0,0 @@
|
|||
AC_DEFUN([AC_FLDIGI_JPEG_HDR], [
|
||||
CXXFLAGS_saved="$CXXFLAGS"
|
||||
m4_ifval([$1], [CXXFLAGS="$CXXFLAGS $1"], [:])
|
||||
AC_CHECK_HEADER([jpeglib.h])
|
||||
CXXFLAGS="$CXXFLAGS_saved"
|
||||
])
|
||||
|
||||
AC_DEFUN([AC_FLDIGI_JPEG_LIB], [
|
||||
CXXFLAGS_saved="$CXXFLAGS"
|
||||
LDFLAGS_saved="$LDFLAGS"
|
||||
m4_ifval([$1], [CXXFLAGS="$CXXFLAGS $1"], [:])
|
||||
m4_ifval([$2], [LDFLAGS="$LDFLAGS $2"], [:])
|
||||
AC_LANG_PUSH(C++)
|
||||
AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[#include <stdio.h>
|
||||
#include <jpeglib.h>
|
||||
struct jpeg_compress_struct cinfo;]],
|
||||
[] )
|
||||
],
|
||||
[ac_cv_libjpeg=yes], [ac_cv_libjpeg=no] )
|
||||
AC_LANG_POP(C++)
|
||||
CXXFLAGS="$CXXFLAGS_saved"
|
||||
LDFLAGS="$LDFLAGS_saved"
|
||||
])
|
||||
|
||||
AC_DEFUN([AC_FLDIGI_JPEG], [
|
||||
AC_ARG_VAR([LIBJPEG_CFLAGS], [C compiler flags for JPEG])
|
||||
AC_ARG_VAR([LIBJPEG_LIBS], [linker flags for JPEG])
|
||||
|
||||
AC_ARG_WITH([jpeg],
|
||||
AC_HELP_STRING([--with-jpeg], [enable libjpeg support @<:@autodetect@:>@]),
|
||||
[case "${withval}" in
|
||||
yes|no) ac_cv_want_libjpeg="${withval}" ;;
|
||||
*) AC_MSG_ERROR([bad value "${withval}" for --with-jpeg]) ;;
|
||||
esac],
|
||||
[ac_cv_want_libjpeg=check])
|
||||
|
||||
if test "x$ac_cv_want_libjpeg" = "xno"; then
|
||||
ac_cv_libjpeg=no
|
||||
else
|
||||
AC_FLDIGI_JPEG_HDR([$LIBJPEG_CFLAGS])
|
||||
if test "x$ac_cv_header_jpeglib_h" != "xyes"; then
|
||||
ac_cv_libjpeg=no
|
||||
else
|
||||
AC_MSG_CHECKING([for libjpeg])
|
||||
if test "x$LIBJPEG_CFLAGS" != "x" || test "x$LIBJPEG_LIBS" != "x"; then
|
||||
AC_FLDIGI_JPEG_LIB([$LIBJPEG_CFLAGS], [$LIBJPEG_LIBS])
|
||||
else
|
||||
AC_FLDIGI_JPEG_LIB([$FLTK_CFLAGS], [$FLTK_LIBS])
|
||||
if test "x$ac_cv_libjpeg" != "xyes"; then
|
||||
LIBJPEG_LIBS="-ljpeg"
|
||||
AC_FLDIGI_JPEG_LIB([$LIBJPEG_CFLAGS], [$LIBJPEG_LIBS])
|
||||
fi
|
||||
fi
|
||||
AC_MSG_RESULT([$ac_cv_libjpeg])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$ac_cv_libjpeg" = "xyes"; then
|
||||
AC_DEFINE([USE_LIBJPEG], 1, [Define to 1 if we are using libjpeg])
|
||||
else
|
||||
AC_DEFINE([USE_LIBJPEG], 0, [Define to 1 if we are using libjpeg])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
AC_DEFUN([AC_FLDIGI_PNG_HDR], [
|
||||
CXXFLAGS_saved="$CXXFLAGS"
|
||||
m4_ifval([$1], [CXXFLAGS="$CXXFLAGS $1"], [:])
|
||||
AC_CHECK_HEADER([png.h])
|
||||
CXXFLAGS="$CXXFLAGS_saved"
|
||||
])
|
||||
|
||||
AC_DEFUN([AC_FLDIGI_PNG_LIB], [
|
||||
CXXFLAGS_saved="$CXXFLAGS"
|
||||
LDFLAGS_saved="$LDFLAGS"
|
||||
m4_ifval([$1], [CXXFLAGS="$CXXFLAGS $1"], [:])
|
||||
m4_ifval([$2], [LDFLAGS="$LDFLAGS $2"], [:])
|
||||
AC_LANG_PUSH(C++)
|
||||
AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[#include <png.h>
|
||||
png_structp png = png_create_write_struct(0, 0, 0, 0);]],
|
||||
[] )
|
||||
],
|
||||
[ac_cv_libpng=yes], [ac_cv_libpng=no] )
|
||||
AC_LANG_POP(C++)
|
||||
CXXFLAGS="$CXXFLAGS_saved"
|
||||
LDFLAGS="$LDFLAGS_saved"
|
||||
])
|
||||
|
||||
AC_DEFUN([AC_FLDIGI_PNG], [
|
||||
AC_ARG_VAR([LIBPNG_CFLAGS], [C compiler flags for PNG])
|
||||
AC_ARG_VAR([LIBPNG_LIBS], [linker flags for PNG])
|
||||
|
||||
AC_ARG_WITH([png],
|
||||
AC_HELP_STRING([--with-png], [enable libpng support @<:@autodetect@:>@]),
|
||||
[case "${withval}" in
|
||||
yes|no) ac_cv_want_libpng="${withval}" ;;
|
||||
*) AC_MSG_ERROR([bad value "${withval}" for --with-png]) ;;
|
||||
esac],
|
||||
[ac_cv_want_libpng=check])
|
||||
|
||||
if test "x$ac_cv_want_libpng" = "xno"; then
|
||||
ac_cv_libpng=no
|
||||
else
|
||||
if test "x$LIBPNG_CFLAGS" != "x" || test "x$LIBPNG_LIBS" != "x"; then
|
||||
AC_FLDIGI_PKG_CHECK([libpng], [libpng >= 1.2.8], [no], [yes])
|
||||
else
|
||||
AC_FLDIGI_PNG_HDR([$LIBPNG_CFLAGS])
|
||||
if test "x$ac_cv_header_png_h" != "xyes"; then
|
||||
AC_FLDIGI_PKG_CHECK([libpng], [libpng >= 1.2.8], [no], [yes])
|
||||
else
|
||||
AC_MSG_CHECKING([for libpng in fltk libs])
|
||||
AC_FLDIGI_PNG_LIB([$FLTK_CFLAGS], [$FLTK_LIBS])
|
||||
AC_MSG_RESULT([$ac_cv_libpng])
|
||||
if test "x$ac_cv_libpng" != "xyes"; then
|
||||
AC_FLDIGI_PKG_CHECK([libpng], [libpng >= 1.2.8], [no], [yes])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$ac_cv_libpng" = "xyes"; then
|
||||
AC_DEFINE([USE_LIBPNG], 1, [Define to 1 if we are using libpng])
|
||||
else
|
||||
AC_DEFINE([USE_LIBPNG], 0, [Define to 1 if we are using libpng])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
AC_DEFUN([AC_FLDIGI_IMAGES], [
|
||||
AC_REQUIRE([AC_FLDIGI_FLTK])
|
||||
|
||||
AC_FLDIGI_JPEG
|
||||
if test "x$ac_cv_libjpeg" = "xyes"; then
|
||||
IMAGE_CFLAGS="$IMAGE_CFLAGS $LIBJPEG_CFLAGS"
|
||||
IMAGE_LIBS="$IMAGE_LIBS $LIBJPEG_LIBS"
|
||||
fi
|
||||
|
||||
AC_FLDIGI_PNG
|
||||
if test "x$ac_cv_libpng" = "xyes"; then
|
||||
IMAGE_CFLAGS="$IMAGE_CFLAGS $LIBPNG_CFLAGS"
|
||||
IMAGE_LIBS="$IMAGE_LIBS $LIBPNG_LIBS"
|
||||
fi
|
||||
|
||||
if test "x$ac_cv_libjpeg" != "xyes" && test "x$ac_cv_libpng" != "xyes"; then
|
||||
AC_MSG_WARN([No image libraries were found])
|
||||
fi
|
||||
|
||||
AC_SUBST([IMAGE_CFLAGS])
|
||||
AC_SUBST([IMAGE_LIBS])
|
||||
])
|
|
@ -37,7 +37,6 @@ private:
|
|||
int width;
|
||||
int height;
|
||||
int depth;
|
||||
int quality;
|
||||
int numcol;
|
||||
int slantdir;
|
||||
void slant_corr(int x, int y);
|
||||
|
@ -54,12 +53,7 @@ public:
|
|||
void clear();
|
||||
void image(Fl_Image *img) {Fl_Widget::image(img);}
|
||||
void resize(int, int, int, int);
|
||||
#if USE_LIBJPEG
|
||||
int save_jpeg(const char *);
|
||||
#endif
|
||||
#if USE_LIBPNG
|
||||
int save_png(const char *);
|
||||
#endif
|
||||
};
|
||||
|
||||
class picbox : public Fl_Box
|
||||
|
|
|
@ -74,38 +74,13 @@ void cb_picRxAbort( Fl_Widget *w, void *)
|
|||
|
||||
void cb_picRxSave( Fl_Widget *w, void *)
|
||||
{
|
||||
const char ffilter[] = ""
|
||||
#if USE_LIBPNG
|
||||
"Portable Network Graphics\t*.png\n"
|
||||
#endif
|
||||
#if USE_LIBJPEG
|
||||
"Independent JPEG Group\t*.{jpg,jpeg}"
|
||||
#endif
|
||||
;
|
||||
const char ffilter[] = "Portable Network Graphics\t*.png\n";
|
||||
string dfname = PicsDir;
|
||||
#if USE_LIBPNG
|
||||
dfname.append("image.png");
|
||||
#else
|
||||
dfname.append("image.jpg");
|
||||
#endif
|
||||
|
||||
int fsel;
|
||||
const char *fn = FSEL::saveas(_("Save image as:"), ffilter, dfname.c_str(), &fsel);
|
||||
if (!fn) return;
|
||||
// selected filter determines format
|
||||
switch (fsel) {
|
||||
case 0:
|
||||
#if USE_LIBPNG
|
||||
const char *fn = FSEL::saveas(_("Save image as:"), ffilter, dfname.c_str(), NULL);
|
||||
if (fn)
|
||||
picRx->save_png(fn);
|
||||
break;
|
||||
#endif
|
||||
// fall through if no libpng
|
||||
case 1:
|
||||
#if USE_LIBJPEG
|
||||
picRx->save_jpeg(fn);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void createRxViewer()
|
||||
|
@ -119,9 +94,6 @@ void createRxViewer()
|
|||
btnpicRxSave = new Fl_Button(5, 140 - 30, 60, 24,_("Save..."));
|
||||
btnpicRxSave->callback(cb_picRxSave, 0);
|
||||
btnpicRxSave->hide();
|
||||
#if !(USE_LIBPNG || USE_LIBJPEG)
|
||||
btnpicRxSave->deactivate();
|
||||
#endif
|
||||
btnpicRxAbort = new Fl_Button(70, 140 - 30, 60, 24, _("Abort"));
|
||||
btnpicRxAbort->callback(cb_picRxAbort, 0);
|
||||
btnpicRxClose = new Fl_Button(135, 140 - 30, 60, 24, _("Hide"));
|
||||
|
@ -239,14 +211,14 @@ void updateTxPic(unsigned char data)
|
|||
}
|
||||
}
|
||||
|
||||
void cb_picTxLoad(Fl_Widget *, void *)
|
||||
void cb_picTxLoad(Fl_Widget *, void *)
|
||||
{
|
||||
const char *fn =
|
||||
const char *fn =
|
||||
FSEL::select(_("Load image file"), "Portable Network Graphics\t*.png\n"
|
||||
"Independent JPEG Group\t*.{jpg,jif,jpeg,jpe}\n"
|
||||
"Graphics Interchange Format\t*.gif", PicsDir.c_str());
|
||||
if (!fn) return;
|
||||
load_image(fn);
|
||||
if (fn)
|
||||
load_image(fn);
|
||||
}
|
||||
|
||||
void cb_picTxClose( Fl_Widget *w, void *)
|
||||
|
|
|
@ -692,15 +692,9 @@ int mfsk::rx_process(const double *buf, int len)
|
|||
}
|
||||
rxstate = RX_STATE_DATA;
|
||||
put_status("");
|
||||
#if USE_LIBPNG
|
||||
|
||||
string autosave_dir = PicsDir;
|
||||
picRx->save_png(autosave_dir.c_str());
|
||||
#else
|
||||
# if USE_LIBJPEG
|
||||
string autosave_dir = PicsDir;
|
||||
picRx->save_jpeg(autosave_dir.c_str());
|
||||
# endif
|
||||
#endif
|
||||
} else
|
||||
recvpic(z);
|
||||
continue;
|
||||
|
|
|
@ -34,19 +34,14 @@
|
|||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/fl_draw.H>
|
||||
|
||||
#if USE_LIBJPEG
|
||||
# include <cstdio>
|
||||
# include <jpeglib.h>
|
||||
#endif
|
||||
#if USE_LIBPNG
|
||||
# include <png.h>
|
||||
#endif
|
||||
#include <png.h>
|
||||
|
||||
#include "fl_lock.h"
|
||||
#include "picture.h"
|
||||
|
@ -60,7 +55,6 @@ picture::picture (int X, int Y, int W, int H) :
|
|||
width = W;
|
||||
height = H;
|
||||
depth = 3;
|
||||
quality = 80; // for jpeg export
|
||||
bufsize = W * H * depth;
|
||||
numcol = 0;
|
||||
slantdir = 0;
|
||||
|
@ -267,53 +261,6 @@ static FILE* open_file(const char* name, const char* suffix)
|
|||
return fp;
|
||||
}
|
||||
|
||||
#if USE_LIBJPEG
|
||||
//
|
||||
// save_jpeg - Write a captured picture to a JPEG format file.
|
||||
//
|
||||
|
||||
int picture::save_jpeg(const char *filename)
|
||||
{
|
||||
unsigned char *ptr; // Pointer to image data
|
||||
FILE *fp = 0; // File pointer
|
||||
struct jpeg_compress_struct info; // Compressor info
|
||||
struct jpeg_error_mgr err; // Error handler info
|
||||
|
||||
if ((fp = open_file(filename, ".jpg")) == NULL)
|
||||
return -1;
|
||||
|
||||
// Setup the JPEG compression stuff...
|
||||
info.err = jpeg_std_error(&err);
|
||||
jpeg_create_compress(&info);
|
||||
jpeg_stdio_dest(&info, fp);
|
||||
|
||||
info.image_width = width;
|
||||
info.image_height = height;
|
||||
info.input_components = depth;
|
||||
info.in_color_space = JCS_RGB;//simg->d() == 1 ? JCS_GRAYSCALE : JCS_RGB;
|
||||
|
||||
jpeg_set_defaults(&info);
|
||||
jpeg_set_quality(&info, quality, 1);
|
||||
jpeg_simple_progression(&info);
|
||||
|
||||
info.optimize_coding = 1;
|
||||
|
||||
// Save the image...
|
||||
jpeg_start_compress(&info, 1);
|
||||
while (info.next_scanline < info.image_height) {
|
||||
ptr = &vidbuf[info.next_scanline * width * depth];
|
||||
jpeg_write_scanlines(&info, &ptr, 1);
|
||||
}
|
||||
jpeg_finish_compress(&info);
|
||||
jpeg_destroy_compress(&info);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif // USE_LIBJPEG
|
||||
|
||||
#if USE_LIBPNG
|
||||
int picture::save_png(const char* filename)
|
||||
{
|
||||
FILE* fp;
|
||||
|
@ -372,7 +319,6 @@ int picture::save_png(const char* filename)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif // USE_LIBPNG
|
||||
|
||||
|
||||
int picbox::handle(int event)
|
||||
|
|
Ładowanie…
Reference in New Issue