当前位置: 首页 > news >正文

麒麟系统播放图片 速度比较

pygame效果比opencv好,opencv有锯齿:

import pygame
import os
import timedef show_image_sdl(image_path):"""使用SDL2快速显示图片"""# 初始化pygamepygame.init()# 获取屏幕信息info = pygame.display.Info()screen_width, screen_height = info.current_w, info.current_h# 创建全屏窗口screen = pygame.display.set_mode((screen_width, screen_height), pygame.FULLSCREEN)pygame.display.set_caption("快速图片查看器")pygame.mouse.set_visible(False)  # 隐藏鼠标# 加载图片try:# 直接加载并转换格式以加速显示image = pygame.image.load(image_path).convert()# 计算缩放比例(屏幕两倍大小)img_width, img_height = image.get_size()scale_x = (screen_width * 1) / img_widthscale_y = (screen_height * 1) / img_heightscale_factor = min(scale_x, scale_y)# 缩放图片new_width = int(img_width * scale_factor)new_height = int(img_height * scale_factor)scaled_image = pygame.transform.smoothscale(image, (new_width, new_height))# 计算居中位置x_pos = (screen_width - new_width) // 2y_pos = (screen_height - new_height) // 2# 显示图片screen.blit(scaled_image, (x_pos, y_pos))pygame.display.flip()print(f"图片显示完成: {new_width}x{new_height}")# 等待退出running = Truewhile running:for event in pygame.event.get():if event.type == pygame.QUIT or \(event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):running = Falsetime.sleep(0.01)  # 减少CPU占用except Exception as e:print(f"错误: {e}")finally:pygame.quit()# 使用
if __name__ == "__main__":show_image_sdl("/home/yklele/hongmeng_s.jpg")

http://www.dtcms.com/a/342821.html

相关文章:

  • 【Python代码】谷歌专利CSV处理函数
  • 【双极性ocl放大电路原理图】2022-11-11
  • 计算机网络:网络基础、TCP编程
  • Seaborn数据可视化实战:Seaborn基础与实践-数据可视化的艺术
  • 数据安全管理——解读银行保险机构数据安全管理办法【附全文阅读】
  • 哈希:最长连续序列
  • 如何根据团队技术能力选择最适合的PHP框架?
  • Python 标准库--python012
  • 机器学习集成算法与K-means聚类
  • Spring两个核心IoCDI(二)
  • 【信创系统】信创系统传输文件
  • 科普:Python 中颜色的格式: RGB 格式 v.s. RGBA 格式
  • Terraform vs Ansible:基础设施即代码(IaC)工具深度对比与实战指南
  • 哈尔滨服务器托管,如何实现高效稳定运行?
  • 泛型与反射
  • MySQL--MVCC
  • MPS MPQ2013AGQ-AEC1-Z MPS芯源汽车级 同步降压转换器IC 电源传感器IC
  • 【密码学】深入浅出栅栏密码:原理、流程与实现
  • Android:compose-Scaffold组件
  • 【CS创世SD NAND征文】存储芯片在工业电表中的应用与技术演进
  • 基于Python与Tkinter开发的微博多功能自动化助手
  • 构建包含IK插件(中文分词插件)的Elasticsearch镜像
  • 分治思想在系统分流削峰中的实践与Golang前沿实现
  • RK3568项目(十六)--linux驱动开发之块设备介绍
  • C++ 序列式容器深度解析:vector、string、deque 与 list
  • 虚幻基础:曲线
  • Go 并发编程-channel
  • Java的反射与枚举
  • 贪吃蛇游戏(纯HTML)
  • 服务发现与负载均衡:Kubernetes Service核心机制深度解析