Majora's Mask - icon2image
Faschz May 21st, 2019 (edited) 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- import cv2
- import numpy
- import os
- def main():
- # Converts the entire directory of icons into a directory of .png images
- # that can be viewed
- for f in os.listdir('/icon/'):
- # This will read the file into a numpy array that OpenCV can use
- # to manipulate and convert into an image of the appropriate format
- img = numpy.fromfile(f, dtype='uint8')
- # The icons are 32x32 RGBA images
- img = img.reshape((32, 32, 4))
- # OpenCV saves the images as BGRA, but Majora's Mask has the icons
- # as RGBA. This will convert them to the correct format
- img = cv2.cvtColor(img, cv2.COLOR_RGBA2BGRA)
- # The output should be the same filename, but instead it is a '.png'
- # instead of a '.bin'
- cv2.imwrite('/image/' + f[-3] + 'png', img)
- if __name__ == "__main__":
RAW Paste Data