summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2011-08-13 18:07:48 +0200
committerJavier S. Pedro <maemo@javispedro.com>2011-08-13 18:07:48 +0200
commita4e1edb7b6b2fdad3b6ad91364f6f666a13c3955 (patch)
tree6d04602ba9c4dcde15ac12975f3ea8be1165ec81
parentfb71caa4758d5cc2f04f8b23d76c74264a7397f9 (diff)
downloadhicg-a4e1edb7b6b2fdad3b6ad91364f6f666a13c3955.tar.gz
hicg-a4e1edb7b6b2fdad3b6ad91364f6f666a13c3955.zip
custom dominant color support
-rw-r--r--index.php29
1 files changed, 28 insertions, 1 deletions
diff --git a/index.php b/index.php
index 4c1ee55..3909f9b 100644
--- a/index.php
+++ b/index.php
@@ -112,7 +112,33 @@ function domcolor_mode($img, $flt)
return false;
}
-$domalgos = array('mean', 'mode');
+
+function domcolor_custom($img, $flt)
+{
+ $color = $_POST['customcolor'];
+
+ /* Remove prefixing '#' if present. */
+ if ($color[0] == '#') $color = substr($color, 1);
+
+ if (strlen($color) == 6) {
+ /* Handle rrggbb format. */
+ $r = $color[0].$color[1];
+ $g = $color[2].$color[3];
+ $b = $color[4].$color[5];
+ } elseif (strlen($color) == 3) {
+ /* Handle rgb format. */
+ $r = $color[0].$color[0];
+ $g = $color[1].$color[1];
+ $b = $color[2].$color[2];
+ } else {
+ /* Unknown format. */
+ return false;
+ }
+
+ return array(hexdec($r), hexdec($g), hexdec($b));
+}
+
+$domalgos = array('mean', 'mode', 'custom');
$colfilters = array('none', 'pure', 'grey', 'grey5');
function extract_dominant_color($svg, $algo = 'average', $filter = 'grey')
@@ -374,6 +400,7 @@ echo '<?xml version="1.0" encoding="utf-8" ?>';
<legend>Algorithm for dominant color extraction</legend>
<label><input type="radio" name="domalgo" value="mean" />Mean / Average</label>
<label><input type="radio" name="domalgo" value="mode" checked="true" />Mode</label>
+ <label><input type="radio" name="domalgo" value="custom" checked="true" />Custom: <input type="text" name="customcolor" /></label>
</fieldset>
<fieldset>
<legend>Colors to ignore</legend>