]>
Commit | Line | Data |
---|---|---|
d74c2284 JB |
1 | --- xv-3.10a/xvjp2k.c.orig 2007-05-14 03:04:37.000000000 +0200 |
2 | +++ xv-3.10a/xvjp2k.c 2023-03-25 17:00:59.872321637 +0100 | |
3 | @@ -68,53 +68,29 @@ static const char *fbasename, /* File's | |
4 | read_err[] = "%s: I/O error reading %s file", | |
5 | bad_dims[] = "%s: error in JPEG-2000 header (bad image size)"; | |
6 | ||
7 | -/* We only want to override the JasPer Library's "jas_eprintf()" subroutine in | |
8 | - order to make it a "wrapper" around XV's own error-reporting subroutine, but | |
9 | - because of the way the former is currently packaged in JasPer Library Version | |
10 | - 1.701, we must override everything else packaged in the "jas_debug.o" module | |
11 | - with it, otherwise we get "duplicate definition" messages from the linker. | |
12 | -*/ | |
13 | -int jas_getdbglevel(void) {return 0;} | |
14 | -int jas_setdbglevel(int n) {return 0;} | |
15 | -int jas_memdump(FILE *fp,void *data,size_t len) {return 0;} | |
16 | - | |
17 | -int jas_eprintf(const char *fmt,...) /* Handle JasPer Library message */ | |
18 | +int jasper_vlogmsgf(jas_logtype_t logtype, const char *fmt,...) /* Handle JasPer Library message */ | |
19 | { | |
20 | - static char error[] = "error: ", warning[]= "warning: "; | |
21 | va_list ap; | |
22 | int kind = ISTR_WARNING; | |
23 | char buffer[512]; | |
24 | register char *p; | |
25 | ||
26 | - /* Unlike the IJG JPEG Library, the JasPer Library current has no graceful way | |
27 | - for an application (= us!) to intercept its diagnostic messages and output | |
28 | - them using our own subroutines, so this ugly replacement for its output | |
29 | - subroutine will have to suffice. At Version 1.701, lthough the library's | |
30 | - own "jas_eprintf()" is a varargs subroutine, all calls currently pass just | |
31 | - 1 string with a Line Feed at the end and no "printf(3C)" arguments. Most | |
32 | - strings begin with "error: " or "warning: ", although a few have neither. | |
33 | - We try to translate these into the format preferred by XV, trimming any | |
34 | - trailing Line Feed character (ugh!). | |
35 | - */ | |
36 | va_start(ap, fmt); | |
37 | vsnprintf(p = buffer,512,fmt,ap); | |
38 | va_end(ap); | |
39 | while (*p++); | |
40 | if (p[-2] == '\n') p[-2] = '\0'; | |
41 | p = buffer; | |
42 | - if (strncmp(p,error,sizeof error) == 0) /* "error: ... " */ | |
43 | + if (jas_logtype_getclass(logtype) == JAS_LOGTYPE_CLASS_ERROR) | |
44 | { | |
45 | kind = ISTR_WARNING; | |
46 | - p += sizeof error; | |
47 | } | |
48 | - else /* "warning: ... " */ | |
49 | - if (strncmp(p,warning,sizeof warning) == 0) | |
50 | + else | |
51 | { | |
52 | kind = ISTR_INFO; | |
53 | - p += sizeof warning; | |
54 | }; | |
55 | SetISTR(kind,"%s: %s",fbasename,p); | |
56 | - return strlen(fmt); | |
57 | + return 0; | |
58 | } | |
59 | ||
60 | static char *SetBuf(FILE *f) | |
61 | @@ -185,7 +185,7 @@ int LoadJPC(char *fname,register PICINFO | |
62 | So, mark the stream buffer proactively: | |
63 | */ | |
64 | str->bufmode_ |= JAS_STREAM_RDBUF; /* We will only read the stream buffer */ | |
65 | - if (!(img = jpc_decode(str,0))) goto L2; | |
66 | + if (!(img = jas_image_decode(str,jas_image_strtofmt("jpc"), 0))) goto L2; | |
67 | if ((vstride = jas_image_numcmpts(img))) /* num. color planes */ | |
68 | { | |
69 | ||
70 | @@ -375,7 +375,7 @@ int LoadJP2(char *fname,register PICINFO | |
71 | So, mark the stream buffer proactively: | |
72 | */ | |
73 | str->bufmode_ |= JAS_STREAM_RDBUF; /* We will only read the stream buffer */ | |
74 | - if (!(img = jp2_decode(str,0))) goto L2; | |
75 | + if (!(img = jas_image_decode(str,jas_image_strtofmt("jp2"), 0))) goto L2; | |
76 | if ((vstride = jas_image_numcmpts(img))) /* num. color planes */ | |
77 | { | |
78 | ||
79 | @@ -674,6 +650,8 @@ void CreateJP2KW(void) | |
80 | }; | |
81 | static const char hstr[]={"Height"}, wstr[]={"Width"}; | |
82 | ||
83 | + jas_conf_set_vlogmsgf(jasper_vlogmsgf); | |
84 | + | |
85 | if (!(jp2kW = CreateWindow( "xvjp2k" | |
86 | , "XVjp2k" | |
87 | , 0 | |
88 | @@ -948,7 +948,7 @@ static void StoreJP2K(char *options) | |
89 | } | |
90 | while (++i <= 2); | |
91 | }; | |
92 | - if ( (*(format == F_JPC ? jpc_encode : jp2_encode))(img,str,options) >= 0 | |
93 | + if (jas_image_encode(img,str,(format == F_JPC) ? "jpc" : "jp2",options) >= 0 | |
94 | && jas_stream_flush(str) >= 0 | |
95 | ) error = 0; /* Success! */ | |
96 | L1: jas_image_destroy(img); |