| 171 | */ |
| 172 | template<class T> |
| 173 | T *item(const int x, const int y, const int c) |
| 174 | { |
| 175 | uint32_t byteIndex = 0; |
| 176 | |
| 177 | if (!m_planar) |
| 178 | byteIndex = (c * m_bytesPerC) + (x * m_bytesPerC * m_numC) + (y * m_rowStride); |
| 179 | else |
| 180 | byteIndex = (c * m_planeStride) + (x * m_bytesPerC) + (y * m_rowStride); |
| 181 | |
| 182 | if (byteIndex >= m_data.size()) |
| 183 | throw std::runtime_error("Requested data out of bounds"); |
| 184 | |
| 185 | return reinterpret_cast<T *>(reinterpret_cast<unsigned char *>(m_data.data()) + byteIndex); |
| 186 | } |
| 187 | |
| 188 | private: |
| 189 | std::vector<uint8_t> m_data; // pointer to local data |