Project setup, and high-level class
This commit is contained in:
parent
db1e74f1d7
commit
0cd22f3bd2
19
Exec/CMakeLists.txt
Normal file
19
Exec/CMakeLists.txt
Normal file
@ -0,0 +1,19 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(BmpPP_exec)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
ADD_COMPILE_DEFINITIONS(_EULE_NO_INTRINSICS_)
|
||||
|
||||
INCLUDE_DIRECTORIES(../Src/Eule/)
|
||||
INCLUDE_DIRECTORIES(../Src/)
|
||||
|
||||
FILE(GLOB Eule ../Src/Eule/Eule/*.cpp)
|
||||
FILE(GLOB BmpPP ../Src/*.cpp)
|
||||
|
||||
add_executable(BmpPP_exec
|
||||
${Eule}
|
||||
${BmpPP}
|
||||
|
||||
main.cpp
|
||||
)
|
9
Exec/main.cpp
Normal file
9
Exec/main.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include <BMP.h>
|
||||
|
||||
using namespace Leonetienne::BmpPP;
|
||||
|
||||
int main() {
|
||||
BMP bmp({800, 600});
|
||||
|
||||
return 0;
|
||||
}
|
29
Src/BMP.cpp
Normal file
29
Src/BMP.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include "BMP.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace Leonetienne::BmpPP {
|
||||
|
||||
BMP::BMP(const Eule::Vector2i &size, const Colormode& colormode)
|
||||
:
|
||||
size { size }
|
||||
{
|
||||
|
||||
pixelBuffer.clear();
|
||||
pixelBuffer.resize(size.x * size.y * ColormodeToPixelSize(colormode));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int BMP::ColormodeToPixelSize(const Colormode &colormode) {
|
||||
|
||||
switch (colormode) {
|
||||
case Colormode::RGB:
|
||||
return 3;
|
||||
case Colormode::RGBA:
|
||||
return 4;
|
||||
|
||||
// Unreachable
|
||||
}
|
||||
}
|
||||
|
||||
}
|
25
Src/BMP.h
Normal file
25
Src/BMP.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef BMPPP_BMP_H
|
||||
#define BMPPP_BMP_H
|
||||
|
||||
#include <Eule/Vector2.h>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include "Colormodes.h"
|
||||
|
||||
namespace Leonetienne::BmpPP {
|
||||
|
||||
class BMP {
|
||||
public:
|
||||
explicit BMP(const Eule::Vector2i& size, const Colormode& colormode = Colormode::RGBA);
|
||||
|
||||
private:
|
||||
//! Will return the corresponding pixel size (in bytes) of a colormode. Like, 3 for RGB and 4 for RGBA.
|
||||
static int ColormodeToPixelSize(const Colormode& colormode);
|
||||
|
||||
Eule::Vector2i size;
|
||||
std::vector<std::uint8_t> pixelBuffer;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //BMPPP_BMP_H
|
@ -9,4 +9,6 @@ FILE(GLOB Eule ./Eule/Eule/*.cpp)
|
||||
|
||||
add_library(BmpPP
|
||||
${Eule}
|
||||
|
||||
BMP.cpp
|
||||
)
|
||||
|
13
Src/Colormodes.h
Normal file
13
Src/Colormodes.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef BMPPP_COLORMODES_H
|
||||
#define BMPPP_COLORMODES_H
|
||||
|
||||
namespace Leonetienne {
|
||||
namespace BmpPP {
|
||||
enum class Colormode {
|
||||
RGB,
|
||||
RGBA
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif //BMPPP_COLORMODES_H
|
Loading…
x
Reference in New Issue
Block a user