gpt4 book ai didi

c++ - 创建 RGB 值为 73,95,105 的背景

转载 作者:太空宇宙 更新时间:2023-11-04 12:34:56 25 4
gpt4 key购买 nike

尝试用上述 RGB 值创建背景,但到目前为止我唯一的成功是加载 jpeg。有没有办法以编程方式创建背景?

#include "CImg.h"

using namespace cimg_library;

constexpr int Height = 600;
constexpr int Width = 539;

int main() {
CImgDisplay mainWindow(Height,Width);
CImg<unsigned char> background;
// background. ??? Is there a function to do so or loading a jpeg the only way
while(!mainWindow.is_closed()) {
mainWindow.display(background);
}

return EXIT_SUCCESS;
}

编辑 1:定义#define cimg_display 2

#define cimg_display 2
#define BACKGROUND_RGB 73,95,105

#include "CImg.h"

using namespace cimg_library;

constexpr int Height = 600;
constexpr int Width = 540;

int main() {
CImgDisplay mainWindow(Height,Width);
CImg<unsigned char> background(Height,Width,1,3,BACKGROUND_RGB);
while(!mainWindow.is_closed()) {
mainWindow.display(background);
}

return EXIT_SUCCESS;
}

CMakefiles.txt

cmake_minimum_required(VERSION 3.14)
project(Snake__)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
include_directories("C:\\C++\\External Library\\CImg-2.6.4\\")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -O3")
add_executable(Snake__ main.cpp)

编译器输出:

Scanning dependencies of target Snake__
[ 50%] Building CXX object CMakeFiles/Snake__.dir/main.cpp.obj
[100%] Linking CXX executable Snake__.exe
[100%] Built target Snake__

Build finished

最佳答案

像这样:

  CImg<unsigned char> background(600,539,1,3,73,95,105);

关于c++ - 创建 RGB 值为 73,95,105 的背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56840490/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com