Add vector to common.h
This commit is contained in:
1 parent
bf09c094e1
commit
e964908e46
6 files changed
+8
-9
No files matched your search
+1
-2
@@ -2,13 +2,12 @@
|
||||
|
||||
#include <fart/Color.h>
|
||||
#include <stddef.h>
|
||||
#include <vector>
|
||||
|
||||
struct Image
|
||||
{
|
||||
size_t width;
|
||||
size_t height;
|
||||
std::vector<Color> pixels;
|
||||
vector<Color> pixels;
|
||||
Image(size_t width, size_t height);
|
||||
|
||||
Color & operator[](size_t x, size_t y)
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
|
||||
Scene * Parser::load_scene(const string_view & input_file)
|
||||
{
|
||||
opt<std::vector<uint8_t>> input = read_file(input_file);
|
||||
opt<vector<uint8_t>> input = read_file(input_file);
|
||||
if (!input)
|
||||
{
|
||||
return nullptr;
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <stdio.h>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
|
||||
static uint8_t to_byte(double v)
|
||||
{
|
||||
@@ -13,7 +12,7 @@ static uint8_t to_byte(double v)
|
||||
|
||||
bool PngImageWriter::write(const Image & image)
|
||||
{
|
||||
std::vector<uint8_t> buffer(image.width * image.height * 4u);
|
||||
vector<uint8_t> buffer(image.width * image.height * 4u);
|
||||
for (size_t i = 0u; i < image.pixels.size(); i++)
|
||||
{
|
||||
const Color & c = image.pixels[i];
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
using string = std::string;
|
||||
using string_view = std::string_view;
|
||||
template <typename T> using opt = std::optional<T>;
|
||||
template <typename T> using vector = std::vector<T>;
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
opt<std::vector<uint8_t>> read_file(string_view fname)
|
||||
opt<vector<uint8_t>> read_file(string_view fname)
|
||||
{
|
||||
string path(fname);
|
||||
FILE * fh = fopen(path.c_str(), "rb");
|
||||
@@ -13,7 +13,7 @@ opt<std::vector<uint8_t>> read_file(string_view fname)
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> buffer;
|
||||
vector<uint8_t> buffer;
|
||||
uint8_t chunk[4096];
|
||||
size_t n;
|
||||
while ((n = fread(chunk, 1u, sizeof(chunk), fh)) > 0u)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
opt<std::vector<uint8_t>> read_file(string_view fname);
|
||||
opt<vector<uint8_t>> read_file(string_view fname);
|
||||
Reference in new issue
Block a user