-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
62 lines (39 loc) · 1.06 KB
/
main.py
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
from PIL import Image
from colormap import rgb2hex
from past.builtins import xrange
import win32gui
image = "cow.jpg" # Change this
offsetx = 0
offsety = 0
loop = True
def get_image(image_path):
global width, height
image = Image.open(image_path, "r")
width, height = image.size
pixel_values = list(image.getdata())
return pixel_values
image = get_image(image)
num = 0
num2 = 0
hdc = win32gui.GetDC(0)
def draw_image(num, num2):
for n in xrange(width * height):
tup = image[n]
r = tup[2]
g = tup[1]
b = tup[0]
hex = rgb2hex(r, g, b).replace("#", "")
hexb = int(hex, 16)
win32gui.SetPixel(hdc, num + offsetx, num2 + offsety, hexb)
if num == width:
num2 += 1
num = 0
num += 1
num2 = 0
# loop
while loop:
draw_image(num, num2)
# no loop
if loop == False:
draw_image(num, num2)
# this was a 3 am coding project and i am VERY tired rn so don't blame me for bad coding!