2016-11-13 17:01:20 -05:00
|
|
|
# Copyright 2016 Virgil Dupras
|
2014-10-13 15:08:59 -04:00
|
|
|
#
|
2015-01-03 16:33:16 -05:00
|
|
|
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
2014-10-13 15:08:59 -04:00
|
|
|
# which should be included with this package. The terms are also available at
|
2015-01-03 16:33:16 -05:00
|
|
|
# http://www.gnu.org/licenses/gpl-3.0.html
|
2009-06-18 19:42:27 +00:00
|
|
|
|
2022-05-09 01:40:08 -05:00
|
|
|
from core.pe._cache import string_to_colors # noqa
|
2019-12-31 20:16:27 -06:00
|
|
|
|
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 15:08:59 -04:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
[(0,100,255)] --> 0064ff
|
|
|
|
[(1,2,3),(4,5,6)] --> 010203040506
|
|
|
|
"""
|
2022-04-27 20:53:12 -05:00
|
|
|
return "".join("{:02x}{:02x}{:02x}".format(r, g, b) for r, g, b in colors)
|
2019-12-31 20:16:27 -06:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2010-01-31 11:25:47 +01: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
|