Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
PictureData.h
Go to the documentation of this file.
1#pragma once
2
4#include "Math/TVector2.h"
5#include "Frame/frame_fwd.h"
6#include "Utility/TSpan.h"
7
8#include <Common/primitive_type.h>
9
10#include <cstddef>
11#include <memory>
12
13namespace ph
14{
15
20class PictureData final
21{
22public:
26
31 math::Vector2S sizePx,
32 std::size_t numPicComponents,
33 EPicturePixelComponent componentType);
34
37 template<typename PixelData>
39 math::Vector2S sizePx,
40 std::size_t numPicComponents,
41 EPicturePixelComponent componentType,
42 const PixelData* pixelData,
43 std::size_t pixelDataSize);
44
45 PictureData(PictureData&& other);
46
47 const math::Vector2S& getSizePx() const;
48 std::size_t getWidthPx() const;
49 std::size_t getHeightPx() const;
50 std::size_t numComponents() const;
54 bool isEmpty() const;
55
61 template<typename PixelData>
62 void setPixels(
63 const PixelData* pixelData,
64 std::size_t numPixelDataElements);
65
66 // TODO: option for allow/disallow lossy conversion?
67 template<typename FrameComponent, std::size_t N>
69
71
72private:
73 template<typename PictureComponent, typename FrameComponent, std::size_t N>
74 TFrame<FrameComponent, N> pictureToFrame() const;
75
76 template<typename PictureComponent>
77 std::size_t getByteIndex(std::size_t xPx, std::size_t yPx, std::size_t componentIndex) const;
78
79 math::Vector2S m_sizePx;
80 std::size_t m_numComponents;
81 EPicturePixelComponent m_componentType;
82 std::unique_ptr<std::byte[]> m_data;
83 std::size_t m_numBytesInData;
84};
85
86}// end namespace ph
87
88#include "Frame/PictureData.ipp"
Definition PictureData.h:21
const math::Vector2S & getSizePx() const
Definition PictureData.ipp:59
PictureData & operator=(PictureData &&rhs)
Definition PictureData.ipp:170
PictureData()
Creates an empty picture.
Definition PictureData.ipp:14
std::size_t getHeightPx() const
Definition PictureData.ipp:69
TSpan< std::byte > getBytes()
Definition PictureData.ipp:84
EPicturePixelComponent getComponentType() const
Definition PictureData.ipp:79
std::size_t getWidthPx() const
Definition PictureData.ipp:64
bool isEmpty() const
Definition PictureData.ipp:165
void setPixels(const PixelData *pixelData, std::size_t numPixelDataElements)
Set pixel data directly. This method also supports packed pixel data. For example,...
Definition PictureData.ipp:95
TFrame< FrameComponent, N > toFrame() const
Definition PictureData.ipp:123
std::size_t numComponents() const
Definition PictureData.ipp:74
Definition TFrame.h:21
The root for all renderer implementations.
Definition EEngineProject.h:6
std::span< const T, EXTENT > TSpanView
Same as TSpan, except that the objects are const-qualified. Note that for pointer types,...
Definition TSpan.h:19
EPicturePixelComponent
Definition picture_basics.h:11
std::span< T, EXTENT > TSpan
A contiguous sequence of objects of type T. Effectively the same as std::span.
Definition TSpan.h:12