aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--GNUmakefile1
-rw-r--r--fb-gui.c6
-rw-r--r--fbi.c9
-rw-r--r--fbtools.c6
-rw-r--r--genthumbnail.c2
-rw-r--r--genthumbnail.h2
-rw-r--r--rd/read-jpeg.c22
7 files changed, 40 insertions, 8 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 0925476..73cd13f 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -8,6 +8,7 @@ resdir = $(DESTDIR)$(RESDIR)
# fixup flags
CFLAGS += -DVERSION='"$(VERSION)"' -I$(srcdir)
+CFLAGS += -Wno-pointer-sign
# default target
all: build
diff --git a/fb-gui.c b/fb-gui.c
index be2eeb8..67a3412 100644
--- a/fb-gui.c
+++ b/fb-gui.c
@@ -47,14 +47,19 @@ linear_palette(int r, int g, int b)
size = 256 >> (8 - r);
for (i = 0; i < size; i++)
p_red[i] = calc_gamma(i,size);
+ p_cmap.len = size;
size = 256 >> (8 - g);
for (i = 0; i < size; i++)
p_green[i] = calc_gamma(i,size);
+ if (p_cmap.len < size)
+ p_cmap.len = size;
size = 256 >> (8 - b);
for (i = 0; i < size; i++)
p_blue[i] = calc_gamma(i,size);
+ if (p_cmap.len < size)
+ p_cmap.len = size;
}
static void
@@ -70,6 +75,7 @@ dither_palette(int r, int g, int b)
p_green[i] = calc_gamma(gs * ((i / b) % g), 255);
p_blue[i] = calc_gamma(bs * ((i) % b), 255);
}
+ p_cmap.len = 256;
}
static void shadow_lut_init_one(int32_t *lut, int bits, int shift)
diff --git a/fbi.c b/fbi.c
index 2c719f8..6446de9 100644
--- a/fbi.c
+++ b/fbi.c
@@ -707,7 +707,7 @@ static float auto_scale(struct ida_image *img)
static int
svga_show(struct ida_image *img, int timeout, char *desc, char *info, int *nr)
{
- static int paused = 0;
+ static int paused = 0, skip = KEY_SPACE;
int exif = 0, help = 0;
int rc;
char key[11];
@@ -718,7 +718,7 @@ svga_show(struct ida_image *img, int timeout, char *desc, char *info, int *nr)
*nr = 0;
if (NULL == img)
- return KEY_SPACE; /* skip */
+ return skip;
if (new_image) {
/* start with centered image, if larger than screen */
@@ -821,6 +821,7 @@ svga_show(struct ida_image *img, int timeout, char *desc, char *info, int *nr)
redraw = 1;
top += text_steps;
} else {
+ skip = KEY_SPACE;
return KEY_SPACE;
}
@@ -850,6 +851,7 @@ svga_show(struct ida_image *img, int timeout, char *desc, char *info, int *nr)
redraw = 1;
top -= text_steps;
} else {
+ skip = KEY_PGUP;
return KEY_PGUP;
}
@@ -862,6 +864,7 @@ svga_show(struct ida_image *img, int timeout, char *desc, char *info, int *nr)
redraw = 1;
top += text_steps;
} else {
+ skip = KEY_PGDN;
return KEY_PGDN;
}
@@ -1122,7 +1125,7 @@ static void edit_desc(struct ida_image *img, char *filename)
static void cleanup_and_exit(int code)
{
shadow_fini();
- fb_clear_mem();
+ fb_clear_screen();
tty_restore();
fb_cleanup();
flist_print_tagged(stdout);
diff --git a/fbtools.c b/fbtools.c
index 563df90..d3ef8a8 100644
--- a/fbtools.c
+++ b/fbtools.c
@@ -449,7 +449,7 @@ fb_init(char *device, char *mode, int vt)
fb_activate_current(tty);
/* cls */
- fb_memset(fb_mem+fb_mem_offset,0,fb_fix.smem_len);
+ fb_memset(fb_mem+fb_mem_offset, 0, fb_fix.line_length * fb_var.yres);
return fb;
err:
@@ -461,6 +461,8 @@ void
fb_cleanup(void)
{
/* restore console */
+ if (-1 == ioctl(tty,KDSETMODE, kd_mode))
+ perror("ioctl KDSETMODE");
if (-1 == ioctl(fb,FBIOPUT_VSCREENINFO,&fb_ovar))
perror("ioctl FBIOPUT_VSCREENINFO");
if (-1 == ioctl(fb,FBIOGET_FSCREENINFO,&fb_fix))
@@ -472,8 +474,6 @@ fb_cleanup(void)
}
close(fb);
- if (-1 == ioctl(tty,KDSETMODE, kd_mode))
- perror("ioctl KDSETMODE");
if (-1 == ioctl(tty,VT_SETMODE, &vt_omode))
perror("ioctl VT_SETMODE");
if (orig_vt_no && -1 == ioctl(tty, VT_ACTIVATE, orig_vt_no))
diff --git a/genthumbnail.c b/genthumbnail.c
index e3c0505..cbe5e9d 100644
--- a/genthumbnail.c
+++ b/genthumbnail.c
@@ -152,7 +152,7 @@ compress_thumbnail(struct ida_image *img, char *dest, int max)
/* ---------------------------------------------------------------------- */
-int create_thumbnail(char *filename, char *dest, int max)
+int create_thumbnail(char *filename, unsigned char *dest, int max)
{
struct ida_image *img,*thumb;
int size;
diff --git a/genthumbnail.h b/genthumbnail.h
index add3ff6..5d4fa80 100644
--- a/genthumbnail.h
+++ b/genthumbnail.h
@@ -1 +1 @@
-int create_thumbnail(char *filename, char *dest, int max);
+int create_thumbnail(char *filename, unsigned char *dest, int max);
diff --git a/rd/read-jpeg.c b/rd/read-jpeg.c
index d12fb40..b6b13f6 100644
--- a/rd/read-jpeg.c
+++ b/rd/read-jpeg.c
@@ -4,6 +4,7 @@
#include <string.h>
#include <errno.h>
#include <jpeglib.h>
+#include <setjmp.h>
#include <libexif/exif-data.h>
@@ -18,6 +19,7 @@ struct jpeg_state {
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
+ jmp_buf errjump;
JSAMPARRAY buffer; /* Output row buffer */
int row_stride,linelength; /* physical row width in output buffer */
unsigned char *image,*ptr;
@@ -65,6 +67,16 @@ static struct jpeg_source_mgr thumbnail_mgr = {
/* ---------------------------------------------------------------------- */
/* jpeg loader */
+static void jerror_exit(j_common_ptr info)
+{
+ struct jpeg_decompress_struct *cinfo = (struct jpeg_decompress_struct *)info;
+ struct jpeg_state *h = container_of(cinfo, struct jpeg_state, cinfo);
+ cinfo->err->output_message(info);
+ longjmp(h->errjump, 1);
+ jpeg_destroy_decompress(cinfo);
+ exit(1);
+}
+
static void*
jpeg_init(FILE *fp, char *filename, unsigned int page,
struct ida_image_info *i, int thumbnail)
@@ -77,6 +89,10 @@ jpeg_init(FILE *fp, char *filename, unsigned int page,
h->infile = fp;
h->cinfo.err = jpeg_std_error(&h->jerr);
+ h->cinfo.err->error_exit = jerror_exit;
+ if(setjmp(h->errjump))
+ return 0;
+
jpeg_create_decompress(&h->cinfo);
jpeg_save_markers(&h->cinfo, JPEG_COM, 0xffff); /* comment */
jpeg_save_markers(&h->cinfo, JPEG_APP0+1, 0xffff); /* EXIF */
@@ -156,6 +172,9 @@ jpeg_read(unsigned char *dst, unsigned int line, void *data)
{
struct jpeg_state *h = data;
JSAMPROW row = dst;
+
+ if(setjmp(h->errjump))
+ return;
jpeg_read_scanlines(&h->cinfo, &row, 1);
}
@@ -163,6 +182,9 @@ static void
jpeg_done(void *data)
{
struct jpeg_state *h = data;
+
+ if (setjmp(h->errjump))
+ return;
jpeg_destroy_decompress(&h->cinfo);
if (h->infile)
fclose(h->infile);