创建 RGB 值为 73,95,105 的背景
Creating a background with RGB value 73,95,105
尝试用上述 RGB 值创建背景,但是到目前为止我唯一的成功是通过加载 jpegs.Is 有没有办法以编程方式创建背景?
#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);
尝试用上述 RGB 值创建背景,但是到目前为止我唯一的成功是通过加载 jpegs.Is 有没有办法以编程方式创建背景?
#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);