MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / set

Method set

source/core/StarImage.cpp:318–333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

316}
317
318void Image::set(Vec2U const& pos, Vec4B const& c) {
319 if (pos[0] >= m_width || pos[1] >= m_height) {
320 throw ImageException(strf("{} out of range in Image::set", pos));
321 } else if (bytesPerPixel() == 4) {
322 size_t offset = pos[1] * m_width * 4 + pos[0] * 4;
323 m_data[offset] = c[0];
324 m_data[offset + 1] = c[1];
325 m_data[offset + 2] = c[2];
326 m_data[offset + 3] = c[3];
327 } else if (bytesPerPixel() == 3) {
328 size_t offset = pos[1] * m_width * 3 + pos[0] * 3;
329 m_data[offset] = c[0];
330 m_data[offset + 1] = c[1];
331 m_data[offset + 2] = c[2];
332 }
333}
334
335void Image::set(Vec2U const& pos, Vec3B const& c) {
336 if (pos[0] >= m_width || pos[1] >= m_height) {

Callers 1

subImageMethod · 0.45

Calls 2

strfFunction · 0.85
bytesPerPixelFunction · 0.85

Tested by

no test coverage detected