如何在C ++中使用Unix在后台使用控制台应用程序中的图像? [英] How Can I Use A Image In Console Application In C++ Using Unix In Background?

查看:85
本文介绍了如何在C ++中使用Unix在后台使用控制台应用程序中的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在后台使用UNIX在C ++中在控制台应用程序中显示图像?

或者如果你可以帮助我使用UNIX中的库,使我们能够在C ++中包含图形。

请帮忙......

提前致谢!!!

解决方案

使用Linux时,可以使用 framebuffer [ ^ ]。



使用帧缓冲区显示图像:



  • 打开帧缓冲设备( / dev / fbX
  • 使用 ioctl 使用 FBIOGET_FSCREENINFO进行调用获取设备信息 FBIOGET_VSCREENINFO
  • 如有必要,将图像转换为帧缓冲设备的颜色深度(例如,使用 avconv 实用程序)
  • 可选择缩放图像
  • 使用 mmap将设备映射到内存
  • 复制图像数据到 mmap返回的内存
  • 关闭映射内存
  • 关闭设备


如果您需要将图像与文本一起显示,还应使用帧缓冲区绘制文本。使用普通的控制台文本输出可能会覆盖图像的某些部分,并可能会将图像滚出视图。



作为库我建议Qt支持多种输出方法,包括帧缓冲。

Is it possible to display an image in console application in C++ using UNIX in background?
Or if you could help me out with the library in UNIX that enables us to include graphics in C++.
Please help...
Thanks in advance!!!

解决方案

When using Linux, you can use the framebuffer[^].

To show an image using the framebuffer:

  • Open the framebuffer device (/dev/fbX)
  • Get the device information using ioctl calls with FBIOGET_FSCREENINFO and FBIOGET_VSCREENINFO
  • If necessary convert the image to the color depth of the framebuffer device (e.g. using the avconv utility)
  • Optionally scale the image
  • Map the device to memory using mmap
  • Copy the image data to the memory returned by mmap
  • Close the mapped memory
  • Close the device

If you need the image to be shown together with text, you should also draw the text using the framebuffer. Using normal console text output might overwrite parts of the image and may scroll the image out of view.

As library I would suggest Qt which supports multiple output methods including framebuffers.


这篇关于如何在C ++中使用Unix在后台使用控制台应用程序中的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆