import cv2
import json
root_dir = "D:\\tmp\\lianai\\"
atlas_img_names = ["btnUI_desktop", "clickUI", "elogo_desktop", "game1UI_desktop", "heartUI", "helpUI_desktop", "levelUI_desktop", "levelUI_desktop", "wedding_desktop", "yanhuaUI"]
print(cv2.__version__)
for atlas_img in atlas_img_names:
json_file = root_dir + atlas_img + ".json"
img_file = root_dir + atlas_img + ".png"
print(img_file)
json_data = json.load(open(json_file))
#print(json_data["frames"])
img = cv2.imread(img_file)
print(img)
for k, v in json_data["frames"].items():
print(k, v)
x = v['x']
y = v['y']
w = v['w']
h = v['h']
sub_img = img[y: y + h, x: x + w, :]
cv2.imwrite(root_dir + "images/" + k.lower() + ".png", sub_img)
03-23
08-29
2642
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交