为什么 SDL 程序不显示 BMP 图片
Why does SDL program not show BMP picture?
我有以下来自Lazy的代码:
#include <iostream>
#include "SDL/SDL.h"
using namespace std;
int main()
{
//Start SDL
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Surface *hello = NULL;
SDL_Surface *screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);
hello = SDL_LoadBMP("hello.bmp");
SDL_BlitSurface(hello, NULL, screen, NULL);
SDL_Flip(screen);
SDL_Delay(3000);
SDL_FreeSurface(hello);
//Quit SDL
SDL_Quit();
return 0;
}
不时显示图片,但大多数时候它只是一个黑色的窗户(这张照片的细线)。我在同一目录中有名为"hello.bmp"的 BMP 文件。附言。我有ArchLinux。
在显示图像之前,应将其转换为与所选视频模式兼容的格式。因此,您应该实现如下内容:
SDL_Surface *imagef;
imagef = SDL_DisplayFormat(image);
在启动 BMP 之前,请将imagef
用于所有操作。
相关文章:
- 如何使用按钮更新GTK3图像以使用C++从相机捕获图片
- 为什么 BMP 图像上的 imwrite 会卡住/不返回?
- 从 bmp 文件数据创建 MFC CBitmap
- 将 bmp 文件加载到 TSpeedButton 中
- 直接 2D 呈现到命令列表和打印:图片压缩
- 佳能SDK无法从相机下载图片
- 图片不显示,关闭时出错 --> 调试断言失败!表达式:is_block_type_valid(标头>_block_use)
- 在C++中的SDL2窗口上显示.bmp时出现问题
- 将位图 (bmp) 转换为具有透明度的 png (Windows c++)
- 将鼠标悬停在图片框上时,如何显示带有 x-y 坐标的十字准线光标?
- 将 BMP 图像转换为灰度
- SystemParametersInfo将背景设置为纯色,而不是实际设置图片
- 黑色纹理,如果图片大小在第二个 OpenGL 线程中> 1 * 1
- glReadPixels() 不返回抗锯齿图片
- GUID variable for JPEG,BMP,PNG
- Qt名称文件图片
- 如何将捕获的图像存储在OpenCV中(将图片保存到计算机)
- 正在加载 sf::图片来自 QDialog
- cuda 和 opencv:我只想要与原始图片相同的图片
- 为什么 SDL 程序不显示 BMP 图片