Sha256: fd1feb38c835abd51d786cdf7d8c31579562ef0d3197387c002c69ca2b7db7ac
Contents?: true
Size: 863 Bytes
Versions: 4
Compression:
Stored size: 863 Bytes
Contents
#include "oily_png_ext.h" PIXEL oily_png_compose_color(PIXEL fg, PIXEL bg) { // Check for simple cases first if ((A_BYTE(fg) == 0xff) || (A_BYTE(bg) == 0x00)) return fg; if (A_BYTE(fg) == 0x00) return bg; // Calculate the new values using fast 8-bit multiplication BYTE a_com = INT8_MULTIPLY(0xff - A_BYTE(fg), A_BYTE(bg)); BYTE new_r = INT8_MULTIPLY(A_BYTE(fg), R_BYTE(fg)) + INT8_MULTIPLY(a_com, R_BYTE(bg)); BYTE new_g = INT8_MULTIPLY(A_BYTE(fg), G_BYTE(fg)) + INT8_MULTIPLY(a_com, G_BYTE(bg)); BYTE new_b = INT8_MULTIPLY(A_BYTE(fg), B_BYTE(fg)) + INT8_MULTIPLY(a_com, B_BYTE(bg)); BYTE new_a = A_BYTE(fg) + a_com; return BUILD_PIXEL(new_r, new_g, new_b, new_a); } VALUE oily_png_color_compose_quick(VALUE self, VALUE fg_color, VALUE bg_color) { return UINT2NUM(oily_png_compose_color(NUM2UINT(fg_color), NUM2UINT(bg_color))); }
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
oily_png-1.0.1 | ext/oily_png/color.c |
oily_png-1.0.0 | ext/oily_png/color.c |
oily_png-1.0.0.rc2 | ext/oily_png/color.c |
oily_png-1.0.0.rc1 | ext/oily_png/color.c |