Spaces:
Sleeping

File size: 2,511 Bytes
28efeac
 
 
2f49e43
28efeac
 
 
 
 
 
 
 
 
 
439a4dc
 
28efeac
 
 
439a4dc
 
 
 
 
b52c5d9
 
 
439a4dc
 
 
2f49e43
28efeac
439a4dc
2f49e43
 
 
 
 
 
 
 
 
 
28efeac
2f49e43
 
 
 
28efeac
 
2f49e43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28efeac
 
 
 
439a4dc
 
28efeac
 
 
 
 
 
 
 
 
2f49e43
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
from PIL import Image


def get_coordinates_from_index(index, width, height):
    if index < 0 or index >= width * height:
        return print("Error: Index out of range")
    x = index % width
    y = index // width
    return x, y


def get_new_coordinates(coordinates):
    x, y = coordinates
    # if x=0 then new_x= 2, if index=1 then new_x= 7, if index=2 then new_x= 12, if index=3 then new_x= 2, if index=4 then new_x= 7, if index=5 then new_x= 12
    new_x = x * 6 + 2
    new_y = y * 6 + 2
    return new_x, new_y


# Increase RGB value by 50 but not (0, 0, 0) values
def increase_rgb_value(color):
    r, g, b = color
    if r == 0 and g == 0 and b == 0:
        return r, g, b
    r += 100
    g += 100
    b += 100
    return r, g, b


def draw_new_pixel(image, coordinates, color):
    x, y = coordinates
    color = increase_rgb_value(color)
    image.putpixel(coordinates, color)
    image.putpixel((x + 1, y), color)
    image.putpixel((x + 2, y), color)
    image.putpixel((x - 1, y), color)
    image.putpixel((x - 2, y), color)

    image.putpixel((x, y + 1), color)
    image.putpixel((x, y + 2), color)
    image.putpixel((x, y - 1), color)
    image.putpixel((x, y - 2), color)

    image.putpixel((x + 1, y + 1), color)
    image.putpixel((x - 1, y - 1), color)
    image.putpixel((x + 1, y - 1), color)
    image.putpixel((x - 1, y + 1), color)


def simulate_bitmap(image):
    width, height = image.size

    list_of_pixels = list(image.getdata())

    # Calculate new Canvas size
    new_width = width * 6
    new_height = height * 6

    # Create new image
    new_image = Image.new("RGB", (new_width, new_height))

    width, height = image.size
    list_of_pixels = list(image.getdata())
    for index, color in enumerate(list_of_pixels):
        draw_new_pixel(
            new_image,
            get_new_coordinates(get_coordinates_from_index(index, width, height)),
            color,
        )
    new_image.save("tmp/simulated_bitmap.bmp")
    return new_image


""" # Open the original .bmp file
image = Image.open("output/combined_output.bmp")

width, height = image.size

list_of_pixels = list(image.getdata())

print(list_of_pixels)

# Calculate new Canvas size
new_width = width * 6
new_height = height * 6

# Create new image
new_image = Image.new("RGB", (new_width, new_height))


# Draw new image
for index, color in enumerate(list_of_pixels):
    draw_new_pixel(get_new_coordinates(get_coordinates_from_index(index)), color)

new_image.save("output/output.bmp") """