156 lines
6.6 KiB
Python
156 lines
6.6 KiB
Python
import sys
|
|
import os
|
|
from os import listdir
|
|
from os.path import isfile, join
|
|
from PIL import Image, ImageEnhance, ImageDraw
|
|
#from PIL import
|
|
import shutil
|
|
|
|
# 0:NORMAL, 1:HOVER, 2:PRESSED, 3:DISABLED
|
|
|
|
TYPE_BUTTON = 0
|
|
TYPE_STATIC = 1
|
|
TYPE_STATIC2 = 2 # NORMAL 2 가 존재함
|
|
TYPE_STATIC3 = 3 # NORMAL-> ALPHA DISABLE (3) 생성
|
|
|
|
#src_path = 'C:\\home\\roadmovie\\project\\fm_viewer\\res\\fmproject\\guide.jpg'
|
|
|
|
src_path_guide = 'C:\\home\\temp\\image\\nexian_src\\nexian_guide.png'
|
|
src_path_normal = 'C:\\home\\temp\\image\\nexian_src\\nexian_normal.png'
|
|
src_path_normal2 = 'C:\\home\\temp\\image\\nexian_src\\nexian_normal2.png'
|
|
src_path_focused = 'C:\\home\\temp\\image\\nexian_src\\nexian_focused.png'
|
|
src_path_pressed = 'C:\\home\\temp\\image\\nexian_src\\nexian_selected.png'
|
|
src_path_disabled = 'C:\\home\\temp\\image\\nexian_src\\nexian_disable.png'
|
|
|
|
target_path = 'C:\\home\\temp\\image\\nexian\\'
|
|
#target_path = r'C:\home\roadmovie\project\fm_viewer\res\emt_kr'
|
|
crop_info = [ ('title_bg',(0,0,1,42),TYPE_STATIC),
|
|
('title_logo',(8,5,145,33),TYPE_STATIC),
|
|
('title_report',(736,3,36,36),TYPE_BUTTON),
|
|
('title_split',(774,3,36,36),TYPE_BUTTON),
|
|
('title_capture',(812,3,36,36 ),TYPE_BUTTON),
|
|
('title_map',(850,3,36,36 ),TYPE_BUTTON),
|
|
('title_setup',(888,3,36,36),TYPE_BUTTON),
|
|
('title_info',(926,3,36,36),TYPE_BUTTON),
|
|
('title_minimize',(974,3,36,36),TYPE_BUTTON),
|
|
('title_close',(1012,3,36,36),TYPE_BUTTON),
|
|
('title_maximize',(661,3,36,36),TYPE_BUTTON),
|
|
('title_seperator',(966,3,5,36),TYPE_STATIC),
|
|
('title_normal',(698,3,36,36),TYPE_BUTTON),
|
|
('title_video_front',(5,51,107,20),TYPE_STATIC),
|
|
('title_video_rear',(699,51,107,20),TYPE_STATIC),
|
|
('vt_swap',(547,48,30,26),TYPE_BUTTON),
|
|
('vt_flip_h',(583,48,30,26),TYPE_BUTTON),
|
|
('vt_flip_v',(620,48,30,26),TYPE_BUTTON),
|
|
('vt_fullscreen',(656,48,30,26),TYPE_BUTTON),
|
|
('vt_fullscreen_checked',(511,48,30,26),TYPE_BUTTON),
|
|
('vt_ch3',(475,48,30,26),TYPE_BUTTON),
|
|
('vt_ch3_checked',(869,48,30,26),TYPE_BUTTON),
|
|
('vt_360wide',(438,48,30,26),TYPE_BUTTON),
|
|
('vt_360normal',(402,48,30,26),TYPE_BUTTON),
|
|
('logo_front_big',(189,117,320,320),TYPE_STATIC2),
|
|
('logo_rear_small',(746,135,260,95),TYPE_STATIC),
|
|
('logo_rear_big',(189,117,320,320),TYPE_STATIC2),
|
|
('logo_front_small',(746,135,260,95),TYPE_STATIC),
|
|
('title_list',(699,312,136,22),TYPE_STATIC),
|
|
('backup',(1001,311,44,24),TYPE_BUTTON),
|
|
('type_all',(710,337,49,26),TYPE_STATIC3),
|
|
('type_normal',(787,337,31 ,26),TYPE_STATIC3),
|
|
('type_manual',(854,337,31,26),TYPE_STATIC3),
|
|
('type_event',(906,337,59,26),TYPE_STATIC3),
|
|
('type_park',(973,337,66,26),TYPE_STATIC3),
|
|
('slider_knob',(365,466,8,18),TYPE_BUTTON),
|
|
('slider_knob_small',(92,583,4,14),TYPE_BUTTON),
|
|
('v_constrast',(12,575,30,30),TYPE_BUTTON),
|
|
('v_brightness',(177,575,30,30),TYPE_BUTTON),
|
|
('v_volume',(340,575,30,30),TYPE_BUTTON),
|
|
('v_volume_checked',(340,545,30,30),TYPE_BUTTON),
|
|
('v_speed',(503,575,30,30),TYPE_BUTTON),
|
|
('sensor_x',(94,497,30,25),TYPE_BUTTON),
|
|
('sensor_y',(94,522,30,25),TYPE_BUTTON),
|
|
('sensor_z',(94,547,30,25),TYPE_BUTTON),
|
|
('speed_kmh',(6,548,87,23),TYPE_BUTTON),
|
|
('speed_mph',(6,525,87,23),TYPE_BUTTON),
|
|
('graph_up',(663,498,28,36),TYPE_BUTTON),
|
|
('graph_down',(663,535,28,36),TYPE_BUTTON),
|
|
('graph_seperator',(663,533,28,3),TYPE_STATIC),
|
|
('play_bg',(5,605,1,71),TYPE_STATIC),
|
|
('play_stop',(22,611,62,62),TYPE_BUTTON), # 1
|
|
('play_play',(94,611,62,62),TYPE_BUTTON), # 2
|
|
('play_previous',(166,611,62,62),TYPE_BUTTON), # 3
|
|
('play_backward',(238,611,62,62),TYPE_BUTTON), # 4
|
|
('play_play_checked',(310,611,62,62),TYPE_BUTTON), # 5
|
|
('play_forward',(382,611,62,62),TYPE_BUTTON), # 6
|
|
('play_next',(454,611,62,62),TYPE_BUTTON), # 7
|
|
('play_seperator',(570,606,3,70),TYPE_STATIC),
|
|
('open',(572,606,121,70),TYPE_BUTTON),
|
|
]
|
|
|
|
def cropImages():
|
|
src_normal = Image.open(src_path_normal)
|
|
src_normal2 = Image.open(src_path_normal2)
|
|
src_focused = Image.open(src_path_focused)
|
|
src_pressed = Image.open(src_path_pressed)
|
|
src_disabled = Image.open(src_path_disabled)
|
|
#print(src)
|
|
#images = list(crop_info.keys())
|
|
for each_image in crop_info:
|
|
title = each_image[0]
|
|
#print(each_image,crop_info[each_image])
|
|
crop = each_image[1]
|
|
control_type = each_image[2]
|
|
|
|
if control_type == TYPE_STATIC2:
|
|
im = src_normal2.crop((crop[0],crop[1],crop[0]+crop[2],crop[1]+crop[3]))
|
|
else:
|
|
im = src_normal.crop((crop[0],crop[1],crop[0]+crop[2],crop[1]+crop[3]))
|
|
|
|
# libpng warning: iCCP: known incorrect sRGB profile 에러 제거?
|
|
#im.info.pop('icc_profile', None)
|
|
|
|
dest_path = join(target_path, title + '.png')
|
|
print(dest_path)
|
|
im.save(dest_path,'PNG',icc_profile=None)
|
|
|
|
if control_type == TYPE_STATIC3:
|
|
im3 = im.copy()
|
|
alpha = im3.split()[3]
|
|
alpha = ImageEnhance.Brightness(alpha).enhance(0.5)
|
|
im3.putalpha(alpha)
|
|
dest_path = join(target_path, title + '_3.png')
|
|
im3.save(dest_path,'PNG',icc_profile=None)
|
|
continue
|
|
|
|
if control_type != TYPE_BUTTON:
|
|
continue
|
|
|
|
im = src_focused.crop((crop[0],crop[1],crop[0]+crop[2],crop[1]+crop[3]))
|
|
im.save(join(target_path, title + '_1.png'),'PNG',icc_profile=None)
|
|
|
|
im = src_pressed.crop((crop[0],crop[1],crop[0]+crop[2],crop[1]+crop[3]))
|
|
im.save(join(target_path, title + '_2.png'),'PNG',icc_profile=None)
|
|
|
|
im = src_disabled.crop((crop[0],crop[1],crop[0]+crop[2],crop[1]+crop[3]))
|
|
im.save(join(target_path, title + '_3.png'),'PNG',icc_profile=None)
|
|
|
|
return
|
|
|
|
def guideImages():
|
|
src = Image.open(src_path_guide)
|
|
draw = ImageDraw.Draw(src, "RGBA")
|
|
for each_image in crop_info:
|
|
#title = each_image[0]
|
|
crop = each_image[1]
|
|
control_type = each_image[2]
|
|
if control_type is TYPE_BUTTON:
|
|
line_color = (255,0,255)
|
|
else:
|
|
line_color = (0,255,255)
|
|
draw.rectangle(((crop[0], crop[1]),(crop[0]+crop[2]-1, crop[1]+crop[3]-1)),outline=line_color,width=1,fill=(None))
|
|
dest_path = join(r'C:\home\temp\image\nexian_src','guide_processed.png')
|
|
src.save(dest_path,'PNG')
|
|
|
|
|
|
cropImages()
|
|
#guideImages()
|