pixelflut/eh18-image.py

47 lines
1.1 KiB
Python
Raw Normal View History

2018-03-31 10:10:00 +00:00
import socket
import random
import time
from PIL import Image
TCP_IP = '94.45.232.48'
TCP_PORT = 1234
BUFFER_SIZE = 4096
flutwidth = 1920
flutheight = 1080
width=200
height=200
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
c = '000000'
im = Image.open("ctdo.png")
rgb_im = im.convert('RGB')
if __name__ == '__main__':
for a in range(100000):
#xv=random.randint(0,flutwidth)
#yv=random.randint(0,flutheight)
xv=flutwidth-width/2
yv=height/2
for i in range(width):
pixel_x=i-width/2+xv
for j in range(height):
pixel_y=j-height/2+yv
#v1=hex(random.randint(0,255))[2:]
#c=v1+v1+v1
r, g, b = rgb_im.getpixel((i, j))
#c=hex(r)+hex(g)+hex(b)
#c=hex(r)
#s.send("PX {0} {1} {2}\n".format(pixel_x, pixel_y, c))
s.send( ('PX %d %d %02x%02x%02x\n' % (pixel_x,pixel_y,r,g,b)).encode())
print(".")
exit()