You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During lunch time I asked chatgpt to convert pascal code to generate .clk file (because I'm on mac and file converter need windows platform) and here the result; I'll take some time later to see if it's working, but looks good.
fromPILimportImageimportosdefconvert_image(input_file_path, output_file_name):
# Load the imageimg=Image.open(input_file_path)
W, H=img.size# Construct the output file pathoutput_file_path=os.path.join(os.path.dirname(input_file_path), output_file_name+'.clk')
# Prepare the headerheader=bytearray([ord('C'), ord('K'), W&0xFF, (W>>8) &0xFF, H&0xFF, (H>>8) &0xFF])
# Create a memory stream (byte array) and write the headermemory_stream=bytearray()
memory_stream.extend(header)
# Process and write pixel dataforyinrange(H):
forxinrange(W):
R, G, B=img.getpixel((x, y))
OutPixel= ((R&0xF8) <<8) | ((G&0xFC) <<3) | (B>>3)
memory_stream.extend(OutPixel.to_bytes(2, byteorder='little'))
# Save to filewithopen(output_file_path, 'wb') asfile:
file.write(memory_stream)
# Example, loop through the image files named RETRO0.jpg to RETRO9.jpg# convert them to bmp renaming them from 40 to 49 and finally convert the# bmp to clk fileforiinrange(10):
# Open each jpg image fileimg=Image.open(f"RETRO{i}.jpg")
# Crop the image to the specified coordinates (left, upper, right, lower)#cropped_img = img.crop((12, 22, 120, 220))# Save the cropped image as a bmp file named 40.bmp to 49.bmp#cropped_img.save(f"4{i}.bmp")img.save(f"4{i}.bmp")
# Convert the bmp to clkconvert_image(f"4{i}.bmp", f"4{i}.clk")
The text was updated successfully, but these errors were encountered:
During lunch time I asked chatgpt to convert pascal code to generate
.clk
file (because I'm on mac and file converter need windows platform) and here the result; I'll take some time later to see if it's working, but looks good.The text was updated successfully, but these errors were encountered: