From 153781888eb5633d2622911fce9afd807ce38e55 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Wed, 1 Sep 2004 05:41:26 +0000 Subject: [PATCH] this should make a lot of themers happy. edje_cc (and edje_recc) now support: -no-lossy Do NOT allow images to be lossy -no-comp Do NOT allow images to be lossless compression -no-raw Do NOT allow images to be zero compression -min-quality VAL Do NOT allow lossy images with quality > VAL (0-100) -max-quality VAL Do NOT allow lossy images with quality < VAL (0-100) this lest you forcibly make a theme .eet that is full quality with NO compression of images, or just lossless compression (recommended for distribution as an "original" .eet) and then make lossy only ones with min and max quality levels.... so u can make small small small themes by just giving up quality :) SVN revision: 11489 --- legacy/edje/src/bin/edje_cc.c | 37 +++++++++++++++++++++ legacy/edje/src/bin/edje_cc.h | 6 ++++ legacy/edje/src/bin/edje_cc_out.c | 38 +++++++++++++++++++--- legacy/edje/src/bin/edje_decc.c | 2 +- legacy/edje/src/bin/edje_recc | 54 ++++++++++++++++++++++++++++--- 5 files changed, 128 insertions(+), 9 deletions(-) diff --git a/legacy/edje/src/bin/edje_cc.c b/legacy/edje/src/bin/edje_cc.c index e20774798b..fb9eb69d2e 100644 --- a/legacy/edje/src/bin/edje_cc.c +++ b/legacy/edje/src/bin/edje_cc.c @@ -9,6 +9,12 @@ char *file_out = NULL; char *progname = NULL; int verbose = 0; +int no_lossy = 0; +int no_comp = 0; +int no_raw = 0; +int min_quality = 0; +int max_quality = 100; + static void main_help(void) { @@ -21,6 +27,11 @@ main_help(void) "-id image/directory Add a directory to look in for relative path images\n" "-fd font/directory Add a directory to look in for relative path fonts\n" "-v Verbose output\n" + "-no-lossy Do NOT allow images to be lossy\n" + "-no-comp Do NOT allow images to be lossless compression\n" + "-no-raw Do NOT allow images to be zero compression\n" + "-min-quality VAL Do NOT allow lossy images with quality > VAL (0-100)\n" + "-max-quality VAL Do NOT allow lossy images with quality < VAL (0-100)\n" ,progname); } @@ -43,6 +54,18 @@ main(int argc, char **argv) { verbose = 1; } + else if (!strcmp(argv[i], "-no-lossy")) + { + no_lossy = 1; + } + else if (!strcmp(argv[i], "-no-comp")) + { + no_comp = 1; + } + else if (!strcmp(argv[i], "-no-raw")) + { + no_raw = 1; + } else if ((!strcmp(argv[i], "-id")) && (i < (argc - 1))) { i++; @@ -53,6 +76,20 @@ main(int argc, char **argv) i++; fnt_dirs = evas_list_append(fnt_dirs, argv[i]); } + else if ((!strcmp(argv[i], "-min-quality")) && (i < (argc - 1))) + { + i++; + min_quality = atoi(argv[i]); + if (min_quality < 0) min_quality = 0; + if (min_quality > 100) min_quality = 100; + } + else if ((!strcmp(argv[i], "-max-quality")) && (i < (argc - 1))) + { + i++; + max_quality = atoi(argv[i]); + if (max_quality < 0) max_quality = 0; + if (max_quality > 100) max_quality = 100; + } else if (!file_in) file_in = argv[i]; else if (!file_out) diff --git a/legacy/edje/src/bin/edje_cc.h b/legacy/edje/src/bin/edje_cc.h index 7650ec43f5..a3cd062462 100644 --- a/legacy/edje/src/bin/edje_cc.h +++ b/legacy/edje/src/bin/edje_cc.h @@ -128,6 +128,11 @@ extern char *file_in; extern char *file_out; extern char *progname; extern int verbose; +extern int no_lossy; +extern int no_comp; +extern int no_raw; +extern int min_quality; +extern int max_quality; extern int line; extern Evas_List *stack; extern Evas_List *params; @@ -138,4 +143,5 @@ extern Evas_List *codes; extern New_Object_Handler object_handlers[]; extern New_Statement_Handler statement_handlers[]; + #endif diff --git a/legacy/edje/src/bin/edje_cc_out.c b/legacy/edje/src/bin/edje_cc_out.c index 9486bd8ad4..d8c3b490b3 100644 --- a/legacy/edje/src/bin/edje_cc_out.c +++ b/legacy/edje/src/bin/edje_cc_out.c @@ -265,17 +265,47 @@ data_write(void) im_data = imlib_image_get_data_for_reading_only(); if ((im_data) && (im_w > 0) && (im_h > 0)) { + int mode, qual; + snprintf(buf, sizeof(buf), "images/%i", img->id); - if (img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT) + mode = 2; + if ((img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT) && + (img->source_param == 0)) + mode = 0; /* RAW */ + else if ((img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT) && + (img->source_param == 1)) + mode = 1; /* COMPRESS */ + else + mode = 2; /* LOSSY */ + if ((mode == 0) && (no_raw)) mode = 1; /* promote compression */ + if ((mode == 2) && (no_lossy)) mode = 1; /* demote compression */ + if ((mode == 1) && (no_comp)) + { + if (no_lossy) mode = 0; /* demote compression */ + else if (no_raw) mode = 2; /* no choice. lossy */ + } + qual = 80; + if (mode == 2) + { + qual = img->source_param; + if (qual < min_quality) qual = min_quality; + if (qual > max_quality) qual = max_quality; + } + if (mode == 0) bytes = eet_data_image_write(ef, buf, im_data, im_w, im_h, im_alpha, - img->source_param, 0, 0); - else + 0, 0, 0); + else if (mode == 1) + bytes = eet_data_image_write(ef, buf, + im_data, im_w, im_h, + im_alpha, + 1, 0, 0); + else if (mode == 2) bytes = eet_data_image_write(ef, buf, im_data, im_w, im_h, im_alpha, - 0, img->source_param, 1); + 0, qual, 1); if (bytes <= 0) { fprintf(stderr, "%s: Error. unable to write image part \"%s\" as \"%s\" part entry to %s \n", diff --git a/legacy/edje/src/bin/edje_decc.c b/legacy/edje/src/bin/edje_decc.c index b6305d5d4a..32b17ead58 100644 --- a/legacy/edje/src/bin/edje_decc.c +++ b/legacy/edje/src/bin/edje_decc.c @@ -251,7 +251,7 @@ output(void) } f = fopen(out, "w"); fprintf(f, "#!/bin/sh\n"); - fprintf(f, "edje_cc -id . -fd . main_edje_source.edc %s.eet\n", outdir); + fprintf(f, "edje_cc $@ -id . -fd . main_edje_source.edc %s.eet\n", outdir); fclose(f); chmod(out, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP); } diff --git a/legacy/edje/src/bin/edje_recc b/legacy/edje/src/bin/edje_recc index 12cfeafd8c..d5de6b71bc 100644 --- a/legacy/edje/src/bin/edje_recc +++ b/legacy/edje/src/bin/edje_recc @@ -2,12 +2,58 @@ set -e -if [ $# -ne 1 ]; then - echo "Usage: edje_recc input_file.eet" +usage () { + echo "Usage:" + echo " edje_recc [OPTIONS] input_file.eet" + echo "" + echo "Where OPTIONS is one or more of:" + echo "" + echo "-v Verbose output" + echo "-no-lossy Do NOT allow images to be lossy" + echo "-no-comp Do NOT allow images to be lossless compression" + echo "-no-raw Do NOT allow images to be zero compression" + echo "-min-quality VAL Do NOT allow lossy images with quality > VAL (0-100)" + echo "-max-quality VAL Do NOT allow lossy images with quality < VAL (0-100)" exit -1 +} + +if [ $# -lt 1 ]; then + usage +fi + +OPT="" +if [ $# -ge 1 ]; then + for I in $@; do + case "$I" in + -h) + usage + ;; + + -help) + usage + ;; + + --help) + usage + ;; + + *.eet) + IN=$I + ;; + + *) + OPT=$OPT" "$I + ;; + esac + done +fi + +if [ -z "$IN" ]; then + echo "ERROR: NO input file.eet provided!" + echo "" + usage; fi -IN=$1 F=`basename $IN` B=`basename $F .eet` T="./...edje_tmp" @@ -17,7 +63,7 @@ cp $IN $T cd $T edje_decc $F cd $B -./build.sh +./build.sh $OPT cd ../.. mv $T/$B/$F $IN rm -rf $T