Git Product home page Git Product logo

Comments (4)

lometsj avatar lometsj commented on July 18, 2024

下载van太守的RPGviewer,导出曹操传里面的e5数据文件的所有图片
发现序号后面总是跟着-1,写个python脚本把-1全去掉
原bmp图片都是8位不带alpha透明通道的,计划转换为带透明通道的32位bmp

from ccz-wiki.

lometsj avatar lometsj commented on July 18, 2024

用pillow和numpy修改曹操传原本的图片
image
gao'ding搞定

import os
from PIL import Image
import numpy as np

im = Image.open("./anim/Mcall00_1.bmp")
im = im.convert("RGBA")
img_arr = np.array(im)
shape = img_arr.shape

height = shape[0]
width = shape[1]
# print('h ' + str(height) + ' w ' + str(width))

for h in range(height):
    for w in range(width):
        (r,g,b,alpha) = img_arr[h,w]
        if (r,g,b,alpha) == (247,0,255,255):
            img_arr[h,w] = (247,0,255,0)
im2 = Image.fromarray(np.uint8(img_arr))
# im2.show()

im2.save("test","BMP")

from ccz-wiki.

lometsj avatar lometsj commented on July 18, 2024

全部搞定

from hashlib import new
import os
from PIL import Image
import numpy as np

def bmp8bit_convert(src, dst):

    im = Image.open(src)
    im = im.convert("RGBA")
    img_arr = np.array(im)
    shape = img_arr.shape

    height = shape[0]
    width = shape[1]
    # print('h ' + str(height) + ' w ' + str(width))
![image](https://user-images.githubusercontent.com/7191056/169141101-b8fa2fb9-7dd5-4388-b22d-566827cd7488.png)

    for h in range(height):
        for w in range(width):
            (r,g,b,alpha) = img_arr[h,w]
            if (r,g,b,alpha) == (247,0,255,255):
                img_arr[h,w] = (247,0,255,0)
                # print("check once")
    im2 = Image.fromarray(np.uint8(img_arr))
    # im2.show()

    im2.save(dst,"BMP")



old_path = 'C:/Users/tsj/Documents/cczmod/old_img'

path = ''

dirlist = os.walk('../cczmod/old_img')
print(dirlist)
for root, dirs, files in dirlist:
    for file in files:
        old_img = os.path.join(root,file)
        new_path = os.path.join('.\\', 'new_img',os.path.split(root)[-1], file)
        if os.access(os.path.join('.\\', 'new_img',os.path.split(root)[-1]) ,os.F_OK) == False:
            os.mkdir(os.path.join('.\\', 'new_img',os.path.split(root)[-1]))
        print('old path:'+old_img)
        print('new path:'+new_path)
        bmp8bit_convert(old_img, new_path)
# bmp8bit_convert('./test.bmp','./check.bmp')


from ccz-wiki.

lometsj avatar lometsj commented on July 18, 2024

image

from ccz-wiki.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.