You've already forked AiraPulsar
Improvement
This commit is contained in:
2
testfield/visual/README.md
Normal file
2
testfield/visual/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# 总览测试
|
||||
基于 bmp 的通讯功能模型测试
|
63
testfield/visual/main.py
Normal file
63
testfield/visual/main.py
Normal file
@@ -0,0 +1,63 @@
|
||||
from PIL import Image
|
||||
import pygame
|
||||
import sys
|
||||
import time
|
||||
|
||||
colorzone = dict()
|
||||
|
||||
def img():
|
||||
# 打开 BMP 文件
|
||||
bmp_image = Image.open('view.bmp')
|
||||
|
||||
# 获取图像的基本信息
|
||||
width, height = bmp_image.size
|
||||
mode = bmp_image.mode
|
||||
|
||||
print(f"图像宽度: {width}, 高度: {height}, 模式: {mode}")
|
||||
|
||||
# 读取图像数据
|
||||
pixel_data = bmp_image.load() # 获取像素数据
|
||||
|
||||
# 遍历每个像素并打印其 RGB 值
|
||||
minleft = 0x3f3f3f3f
|
||||
mintop = 0x3f3f3f3f
|
||||
for y in range(height):
|
||||
for x in range(width):
|
||||
minleft = min(minleft, x)
|
||||
mintop = min(mintop, y)
|
||||
r, g, b = pixel_data[x, y] # 获取每个像素的 RGB 值
|
||||
if r == 255 and b == 255 and g == 255:
|
||||
pass
|
||||
else:
|
||||
if (r,g,b) in colorzone:
|
||||
colorzone[(r,g,b)].append(((x//8)*4,(y//8)*4))
|
||||
else:
|
||||
colorzone[(r,g,b)] = list()
|
||||
colorzone[(r,g,b)].append((x//8*4,y//8*4))
|
||||
#print(f"像素 ({x}, {y}): R={r}, G={g}, B={b}")
|
||||
|
||||
colorzone[(255,255,255)] = colorzone[(0,0,0)]
|
||||
# 关闭图像
|
||||
bmp_image.close()
|
||||
|
||||
def grap():
|
||||
pygame.init()
|
||||
width, height = 800, 1000
|
||||
screen = pygame.display.set_mode((width, height))
|
||||
pygame.display.set_caption("TEST")
|
||||
global colorzone
|
||||
while True:
|
||||
for i in colorzone.keys():
|
||||
for j in colorzone[i]:
|
||||
if i != (255,255,255):
|
||||
pygame.draw.rect(screen, i, (j[0], j[1], 2, 2)) # 远程波形
|
||||
else:
|
||||
pygame.draw.rect(screen, i, (j[0], j[1], 1, 1)) # 远程波形
|
||||
pygame.display.flip()
|
||||
pygame.time.delay(10)
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("START")
|
||||
img()
|
||||
print("LOADED")
|
||||
grap()
|
BIN
testfield/visual/view.bmp
Normal file
BIN
testfield/visual/view.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 MiB |
17
testfield/visual/viewcfg.yaml
Normal file
17
testfield/visual/viewcfg.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
# 机体: Fuselage -> fuse
|
||||
# 副翼: Aileron -> aile
|
||||
# 襟翼: Flap -> flap
|
||||
# 发动机: Engine -> eng
|
||||
# 控制器: Controller -> ctrl
|
||||
# 方向舵: Rudder -> rud
|
||||
# 俯仰舵: Elevator -> elev
|
||||
marking:
|
||||
|
||||
color_config:
|
||||
fuselage: (255,255,255)
|
||||
aileron: ()
|
||||
flap:
|
||||
engine:
|
||||
controller: (255,255,255)
|
||||
rudder:
|
||||
elevator:
|
Reference in New Issue
Block a user