summaryrefslogtreecommitdiff
path: root/support/dktools/hbimgdim.c
diff options
context:
space:
mode:
Diffstat (limited to 'support/dktools/hbimgdim.c')
-rw-r--r--support/dktools/hbimgdim.c123
1 files changed, 70 insertions, 53 deletions
diff --git a/support/dktools/hbimgdim.c b/support/dktools/hbimgdim.c
index 59b5b8e333..075f2f968f 100644
--- a/support/dktools/hbimgdim.c
+++ b/support/dktools/hbimgdim.c
@@ -1,36 +1,14 @@
/*
- WARNING: This file was generated by dkct.
- Changes you make here will be lost if dkct is run again!
- You should modify the original source and run dkct on it.
- Original source: hbimgdim.ctr
+Copyright (C) 2013-2020, Dirk Krause
+SPDX-License-Identifier: BSD-3-Clause
*/
/*
-Copyright (C) 2013-2017, Dirk Krause
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-* Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above opyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-* Neither the name of the author nor the names of contributors may be used
- to endorse or promote products derived from this software without specific
- prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ WARNING: This file was generated by the dkct program (see
+ http://dktools.sourceforge.net/ for details).
+ Changes you make here will be lost if dkct is run again!
+ You should modify the original source and run dkct on it.
+ Original source: hbimgdim.ctr
*/
/** @file hbimgdim.c The hbimgdim module.
@@ -52,6 +30,41 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/** File name suffixes used by SVG files.
+*/
+static const dkChar * const svg_suffixes[] = {
+ dkT(".svg"), dkT(".svgz"), NULL
+};
+
+
+
+static
+int
+is_svg_file(dkChar const *fn)
+{
+ const dkChar *psuff = NULL;
+ int back = 0;
+ int ind;
+
+
+#line 97 "hbimgdim.ctr"
+ if (NULL != fn) {
+ psuff = dk3str_get_suffix(fn);
+ if (NULL != psuff) {
+ ind = dk3str_array_index(svg_suffixes, psuff, 0);
+ if (-1 < ind) {
+ back = 1;
+ }
+ }
+ }
+
+
+#line 107 "hbimgdim.ctr"
+ return back;
+}
+
+
+
int
hbimgdim_compare(void const *l, void const *r, int cr)
{
@@ -60,7 +73,7 @@ hbimgdim_compare(void const *l, void const *r, int cr)
hb_img_dim_t *pr;
-#line 88 "hbimgdim.ctr"
+#line 119 "hbimgdim.ctr"
if(l) {
if(r) {
pl = (hb_img_dim_t *)l;
@@ -80,7 +93,7 @@ hbimgdim_compare(void const *l, void const *r, int cr)
if(r) back = -1;
}
-#line 106 "hbimgdim.ctr"
+#line 137 "hbimgdim.ctr"
return back;
}
@@ -91,7 +104,7 @@ hbimgdim_delete(hb_img_dim_t *ptr)
{
-#line 115 "hbimgdim.ctr"
+#line 146 "hbimgdim.ctr"
if(ptr) {
dk3_release(ptr->fn);
ptr->w = 0UL;
@@ -99,7 +112,7 @@ hbimgdim_delete(hb_img_dim_t *ptr)
dk3_delete(ptr);
}
-#line 121 "hbimgdim.ctr"
+#line 152 "hbimgdim.ctr"
}
@@ -110,7 +123,7 @@ hbimgdim_new(dkChar const *fn, unsigned long w, unsigned long h, dk3_app_t *app)
hb_img_dim_t *back = NULL;
-#line 130 "hbimgdim.ctr"
+#line 161 "hbimgdim.ctr"
back = dk3_new_app(hb_img_dim_t,1,app);
if(back) {
back->w = w;
@@ -122,7 +135,7 @@ hbimgdim_new(dkChar const *fn, unsigned long w, unsigned long h, dk3_app_t *app)
}
}
-#line 140 "hbimgdim.ctr"
+#line 171 "hbimgdim.ctr"
return back;
}
@@ -144,37 +157,41 @@ hbimgdim_find(
int back = 0;
-#line 160 "hbimgdim.ctr"
+#line 191 "hbimgdim.ctr"
if((job) && (fn) && (w) && (h)) {
- idptr = dk3sto_it_find_like(job->i_imgdim, fn, 1);
+ idptr = (hb_img_dim_t *)dk3sto_it_find_like(job->i_imgdim, fn, 1);
if(idptr) {
*w = idptr->w;
*h = idptr->h;
back = 1;
} else {
- bp = dk3bif_open_filename_app(fn, DK3_BIF_IMAGE_TYPE_UNKNOWN, job->app);
- if(bp) {
- xw = dk3bif_get_width(bp);
- xh = dk3bif_get_height(bp);
- dk3bif_close(bp);
- if((xw) && (xh)) {
- *w = xw;
- *h = xh;
- back = 1;
- if(save) {
- idptr = hbimgdim_new(fn, xw, xh, job->app);
- if(idptr) {
- if(!(dk3sto_add(job->s_imgdim, idptr))) {
- hbimgdim_delete(idptr);
+ if (0 == is_svg_file(fn)) {
+ bp = dk3bif_open_filename_app(fn, DK3_BIF_IMAGE_TYPE_UNKNOWN, job->app);
+ if(bp) {
+ xw = dk3bif_get_width(bp);
+ xh = dk3bif_get_height(bp);
+ dk3bif_close(bp);
+ if((xw) && (xh)) {
+ *w = xw;
+ *h = xh;
+ back = 1;
+ if(save) {
+ idptr = hbimgdim_new(fn, xw, xh, job->app);
+ if(idptr) {
+ if(!(dk3sto_add(job->s_imgdim, idptr))) {
+ hbimgdim_delete(idptr);
+ }
}
}
}
- }
+ }
+ } else {
+ /* TODO: Find SVG width and height */
}
}
}
-#line 188 "hbimgdim.ctr"
+#line 223 "hbimgdim.ctr"
return back;
}