import cv2
import pygame
import sys
from pygame import gfxdraw
import numpy as np
(width, height) = (800, 600)
pygame.init()
screen = pygame.display.set_mode((width, height))
image = pygame.image.load("11.jpg").convert()
image1 = pygame.image.load("1.jpg").convert()
d3=pygame.surfarray.array3d(image)
f=250
sc=300
color=(255, 255, 255)
sarray=pygame.surfarray.array3d(pygame.Surface((width,height)))
tsize=image.get_size()
tsize1=image1.get_size()
print(tsize)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
mouse = pygame.mouse.get_pos()
'''pxarray = pygame.PixelArray(screensurf)
pixel = pygame.Color(pxarray[mouse[0], mouse[1]])#获取像素
print (pixel)
print (screensurf.get_at(mouse))#颜色
print(mouse[0], mouse[1],mouse)#点击坐标
print(img.get_at(mouse))#颜色'''
print(mouse[0], mouse[1], mouse)
for i in range(width):
for j in range(int(height/2),height):
x=(width/2)-i
y=j+f
z=j-(height/2)+0.01
'''
def huizhi(x, y, z):
shiju = 300
x1 = shiju * x / z
y1 = shiju * y / z
# p.append((x1,y1))
return x1, y1
'''
px=x/z*sc
py=y/z*90
'''不重复图片'''
if 0 <= px < tsize[0] and 0 <= py< tsize[1]:
fp = int(px), int(py)
pygame.Surface.set_at(screen, (i, int(j/2)+260), (image.get_at((fp))))
for i in range(width):
for j in range(int(height/2),height):
x=(width/2)-i
y=j+f
z=j-(height/2)+0.01
'''
def huizhi(x, y, z):
shiju = 300
x1 = shiju * x / z
y1 = shiju * y / z
# p.append((x1,y1))
return x1, y1
'''
px=x/z*sc
py=y/z*90
'''不重复图片'''
if 0 <= px < tsize1[0] and 0 <= py< tsize1[1]:
fp = int(px), int(py)
pygame.Surface.set_at(screen, (i+300, int(j/2)+260), (image1.get_at((fp))))
pygame.display.update()