mirror of
https://mikeslab.dix.asia/gogs/My-Mods/ANI2Cape.git
synced 2025-10-01 23:14:57 +00:00
Add padding to solve visual glitch
This commit is contained in:
parent
d8a9ba0713
commit
b4e2de09b2
3 changed files with 15 additions and 12 deletions
|
@ -6,6 +6,7 @@
|
||||||
- 添加了自动计算长宽的功能
|
- 添加了自动计算长宽的功能
|
||||||
a. 长和宽均为-1,则直接从原图取得长宽数值
|
a. 长和宽均为-1,则直接从原图取得长宽数值
|
||||||
b. 长、宽二者之一为-1,则从给定数值的边长计算出缩放倍率并等比缩放
|
b. 长、宽二者之一为-1,则从给定数值的边长计算出缩放倍率并等比缩放
|
||||||
|
- 通过在四周增加2像素padding解决顶格的动态指针边缘出现黑线的问题
|
||||||
|
|
||||||
注:
|
注:
|
||||||
- `ani2cape.py`不接受参数,直接运行即读取同目录下`config.py`内容,其中`Cursors`子项目`Path`属性使用相对路径时基于当前切换到的目录(而不是程序目录)
|
- `ani2cape.py`不接受参数,直接运行即读取同目录下`config.py`内容,其中`Cursors`子项目`Path`属性使用相对路径时基于当前切换到的目录(而不是程序目录)
|
||||||
|
|
14
ani2cape.py
14
ani2cape.py
|
@ -85,8 +85,8 @@ def main():
|
||||||
cursorSetting = {
|
cursorSetting = {
|
||||||
'FrameCount': 1,
|
'FrameCount': 1,
|
||||||
'FrameDuration': cursorConfig['FrameDuration'],
|
'FrameDuration': cursorConfig['FrameDuration'],
|
||||||
'HotSpotX': cursorConfig['HotSpot'][0],
|
'HotSpotX': cursorConfig['HotSpot'][0] + 2.0,
|
||||||
'HotSpotY': cursorConfig['HotSpot'][1],
|
'HotSpotY': cursorConfig['HotSpot'][1] + 2.0,
|
||||||
'Representations': []
|
'Representations': []
|
||||||
}
|
}
|
||||||
hidpiRatio = 2 if capeConfig['HiDPI'] else 1
|
hidpiRatio = 2 if capeConfig['HiDPI'] else 1
|
||||||
|
@ -100,15 +100,17 @@ def main():
|
||||||
for frameIndex in range(len(res['msg'])):
|
for frameIndex in range(len(res['msg'])):
|
||||||
b = io.BytesIO(res['msg'][frameIndex])
|
b = io.BytesIO(res['msg'][frameIndex])
|
||||||
frame, (width, height) = readCUR(b, width, height)
|
frame, (width, height) = readCUR(b, width, height)
|
||||||
position = (0, int(width * frameIndex))
|
position = (2, 2 + int((height + 4) * frameIndex))
|
||||||
if frameIndex == 0:
|
if frameIndex == 0:
|
||||||
spriteSheet = Image.new('RGBA', (int(width), int(height) * len(res['msg'])))
|
spriteSheet = Image.new('RGBA', (int(width + 4), int(height + 4) * len(res['msg'])))
|
||||||
spriteSheet.paste(frame, position)
|
spriteSheet.paste(frame, position)
|
||||||
else:
|
else:
|
||||||
logging.info('尝试作为CUR读入')
|
logging.info('尝试作为CUR读入')
|
||||||
spriteSheet, (width, height) = readCUR(f, width, height)
|
frame, (width, height) = readCUR(f, width, height)
|
||||||
|
spriteSheet = Image.new('RGBA', (int(width + 4), int(height + 4)))
|
||||||
|
spriteSheet.paste(frame, (2, 2))
|
||||||
logging.info(f'目标尺寸:{width}x{height}@{hidpiRatio}x')
|
logging.info(f'目标尺寸:{width}x{height}@{hidpiRatio}x')
|
||||||
cursorSetting['PointsHigh'], cursorSetting['PointsWide'] = width, height
|
cursorSetting['PointsHigh'], cursorSetting['PointsWide'] = width + 4, height + 4
|
||||||
for scale in (1, 2) if capeConfig['HiDPI'] else (1,):
|
for scale in (1, 2) if capeConfig['HiDPI'] else (1,):
|
||||||
byteBuffer = io.BytesIO()
|
byteBuffer = io.BytesIO()
|
||||||
scaleImage(spriteSheet, scale).save(byteBuffer, format='tiff', compression='tiff_lzw')
|
scaleImage(spriteSheet, scale).save(byteBuffer, format='tiff', compression='tiff_lzw')
|
||||||
|
|
12
config.py
12
config.py
|
@ -6,13 +6,13 @@ capeConfig = {
|
||||||
'Cursors': {
|
'Cursors': {
|
||||||
'com.apple.coregraphics.Arrow': {
|
'com.apple.coregraphics.Arrow': {
|
||||||
'FrameDuration': 0.1,
|
'FrameDuration': 0.1,
|
||||||
'HotSpot': (0.0, 0.0),
|
'HotSpot': (2.0, 2.0),
|
||||||
'Size': (32.0, -1.0),
|
'Size': (32.0, 32.0),
|
||||||
'Path': "./Normal.ani"
|
'Path': "./Normal.ani"
|
||||||
},
|
},
|
||||||
'com.apple.coregraphics.Move': {
|
'com.apple.coregraphics.Move': {
|
||||||
'FrameDuration': 0.1,
|
'FrameDuration': 0.1,
|
||||||
'HotSpot': (0.0, 0.0),
|
'HotSpot': (2.0, 2.0),
|
||||||
'Size': (32.0, 32.0),
|
'Size': (32.0, 32.0),
|
||||||
'Path': "./Normal.ani"
|
'Path': "./Normal.ani"
|
||||||
},
|
},
|
||||||
|
@ -36,7 +36,7 @@ capeConfig = {
|
||||||
},
|
},
|
||||||
'com.apple.cursor.40': {
|
'com.apple.cursor.40': {
|
||||||
'FrameDuration': 0.1,
|
'FrameDuration': 0.1,
|
||||||
'HotSpot': (0.0, 0.0),
|
'HotSpot': (2.0, 2.0),
|
||||||
'Size': (32.0, 32.0),
|
'Size': (32.0, 32.0),
|
||||||
'Path': "./Help.ani"
|
'Path': "./Help.ani"
|
||||||
},
|
},
|
||||||
|
@ -54,13 +54,13 @@ capeConfig = {
|
||||||
},
|
},
|
||||||
'com.apple.cursor.2': {
|
'com.apple.cursor.2': {
|
||||||
'FrameDuration': 0.1,
|
'FrameDuration': 0.1,
|
||||||
'HotSpot': (0.0, 0.0),
|
'HotSpot': (2.0, 2.0),
|
||||||
'Size': (32.0, 32.0),
|
'Size': (32.0, 32.0),
|
||||||
'Path': "./Link.ani"
|
'Path': "./Link.ani"
|
||||||
},
|
},
|
||||||
'com.apple.cursor.13': {
|
'com.apple.cursor.13': {
|
||||||
'FrameDuration': 0.1,
|
'FrameDuration': 0.1,
|
||||||
'HotSpot': (0.0, 0.0),
|
'HotSpot': (2.0, 2.0),
|
||||||
'Size': (32.0, 32.0),
|
'Size': (32.0, 32.0),
|
||||||
'Path': "./Link.ani"
|
'Path': "./Link.ani"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue