2016-11-13 22:01:20 +00:00
|
|
|
# Copyright 2016 Virgil Dupras
|
2014-10-13 19:08:59 +00:00
|
|
|
#
|
2015-01-03 21:33:16 +00:00
|
|
|
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
2014-10-13 19:08:59 +00:00
|
|
|
# which should be included with this package. The terms are also available at
|
2015-01-03 21:33:16 +00:00
|
|
|
# http://www.gnu.org/licenses/gpl-3.0.html
|
2009-06-18 19:42:27 +00:00
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
from ._cache import string_to_colors # noqa
|
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
|
|
|
|
def colors_to_string(colors):
|
|
|
|
"""Transform the 3 sized tuples 'colors' into a hex string.
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
[(0,100,255)] --> 0064ff
|
|
|
|
[(1,2,3),(4,5,6)] --> 010203040506
|
|
|
|
"""
|
2020-01-01 02:16:27 +00:00
|
|
|
return "".join("%02x%02x%02x" % (r, g, b) for r, g, b in colors)
|
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2010-01-31 10:25:47 +00:00
|
|
|
# This function is an important bottleneck of dupeGuru PE. It has been converted to C.
|
2009-06-01 09:55:11 +00:00
|
|
|
# def string_to_colors(s):
|
|
|
|
# """Transform the string 's' in a list of 3 sized tuples.
|
|
|
|
# """
|
|
|
|
# result = []
|
|
|
|
# for i in xrange(0, len(s), 6):
|
|
|
|
# number = int(s[i:i+6], 16)
|
|
|
|
# result.append((number >> 16, (number >> 8) & 0xff, number & 0xff))
|
|
|
|
# return result
|