-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathicon_render.py
53 lines (41 loc) · 1.5 KB
/
icon_render.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import cv2
import numpy as np
fungus_types = [
"crimson",
"warped"
]
texture_templates = [
"_fungus_stelum",
"_fungus_head",
"_fungus_details",
"_fungus_details2"
]
# stelum, head, details, details2
stelum_color = 0xffffff
head_color = 0xffffff
details_color = 0xffffff
details2_color = 0xffffff
fungus_colors = [96564928, -1231718516, 751835909, -1044800857]
out_images = []
for texture in texture_templates:
color_index = texture_templates.index(texture)
path = "templates/"+fungus_types[0]+texture+".png"
in_img = cv2.imread(path, cv2.IMREAD_UNCHANGED)
b, g, r, a = cv2.split(in_img)
# extracting channels from fungus_colors
r_val = (fungus_colors[color_index] & 0xFF0000) >> 16
g_val = (fungus_colors[color_index] & 0xFF00) >> 8
b_val = (fungus_colors[color_index] & 0xFF)
# giving color
out_blue_array = np.full((16, 16), b_val, dtype="uint8")
np.multiply(b / 255, out_blue_array, out=out_blue_array, casting="unsafe")
out_green_array = np.full((16, 16), g_val, dtype="uint8")
np.multiply(g / 255, out_green_array, out=out_green_array, casting="unsafe")
out_red_array = np.full((16, 16), r_val, dtype="uint8")
np.multiply(r / 255, out_red_array, out=out_red_array, casting="unsafe")
out_img = cv2.merge([out_blue_array, out_green_array, out_red_array, a])
out_images.append(out_img)
result = np.full((16, 16, 4), 0, dtype="uint8")
for x in out_images:
result += x
cv2.imwrite("icon.png", result)