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

Method get

source/core/StarImage.cpp:352–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

350}
351
352Vec4B Image::get(Vec2U const& pos) const {
353 Vec4B c;
354 if (pos[0] >= m_width || pos[1] >= m_height) {
355 throw ImageException(strf("{} out of range in Image::get", pos));
356 } else if (bytesPerPixel() == 4) {
357 size_t offset = pos[1] * m_width * 4 + pos[0] * 4;
358 c[0] = m_data[offset];
359 c[1] = m_data[offset + 1];
360 c[2] = m_data[offset + 2];
361 c[3] = m_data[offset + 3];
362 } else if (bytesPerPixel() == 3) {
363 size_t offset = pos[1] * m_width * 3 + pos[0] * 3;
364 c[0] = m_data[offset];
365 c[1] = m_data[offset + 1];
366 c[2] = m_data[offset + 2];
367 c[3] = 255;
368 }
369 return c;
370}
371
372void Image::setrgb(Vec2U const& pos, Vec4B const& c) {
373 if (m_pixelFormat == PixelFormat::BGR24 || m_pixelFormat == PixelFormat::BGRA32)

Callers 5

readPngMethod · 0.45
readPngMetadataMethod · 0.45
copyIntoMethod · 0.45
drawIntoMethod · 0.45
writePngMethod · 0.45

Calls 2

strfFunction · 0.85
bytesPerPixelFunction · 0.85

Tested by

no test coverage detected