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

Method drawInto

source/core/StarImage.cpp:448–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

446}
447
448void Image::drawInto(Vec2U const& min, Image const& image) {
449 Vec2U max = (min + image.size()).piecewiseMin(size());
450
451 for (unsigned y = min[1]; y < max[1]; ++y) {
452 for (unsigned x = min[0]; x < max[0]; ++x) {
453 Vec4B dest = get(Vec2U(x, y));
454 Vec4B src = image.get(Vec2U(x, y) - min);
455
456 Vec3U destMultiplied = Vec3U(dest[0], dest[1], dest[2]) * dest[3] / 255;
457 Vec3U srcMultiplied = Vec3U(src[0], src[1], src[2]) * src[3] / 255;
458
459 // Src over dest alpha composition
460 Vec3U over = srcMultiplied + destMultiplied * (255 - src[3]) / 255;
461 unsigned alpha = src[3] + dest[3] * (255 - src[3]) / 255;
462
463 set(x, y, Vec4B(over[0], over[1], over[2], alpha));
464 }
465 }
466}
467
468Image Image::convert(PixelFormat pixelFormat) const {
469 Image converted(m_width, m_height, pixelFormat);

Callers 2

drawNodesFunction · 0.80
defineObjectOrientationFunction · 0.80

Calls 6

sizeFunction · 0.85
getFunction · 0.85
piecewiseMinMethod · 0.80
setFunction · 0.50
sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected