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

Method subImage

source/core/StarImage.cpp:424–437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

422}
423
424Image Image::subImage(Vec2U const& pos, Vec2U const& size) const {
425 if (pos[0] + size[0] > m_width || pos[1] + size[1] > m_height)
426 throw ImageException(strf("call to subImage with pos {} size {} out of image bounds ({}, {})", pos, size, m_width, m_height));
427
428 Image sub(size[0], size[1], m_pixelFormat);
429
430 for (unsigned y = 0; y < size[1]; ++y) {
431 for (unsigned x = 0; x < size[0]; ++x) {
432 sub.set({x, y}, get(pos + Vec2U(x, y)));
433 }
434 }
435
436 return sub;
437}
438
439void Image::copyInto(Vec2U const& min, Image const& image) {
440 Vec2U max = (min + image.size()).piecewiseMin(size());

Callers 3

processImageOperationFunction · 0.80
loadImageMethod · 0.80
makeMethod · 0.80

Calls 3

strfFunction · 0.85
getFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected