21 #include "../exception.h"
22 #include "../utils/utils.hpp"
26 #if defined(BEATMUP_CHANNEL_ORDER_BGRA) && defined(BEATMUP_CHANNEL_ORDER_ARGB)
27 #error Color order definition conflict
84 int sum()
const {
return x; }
85 float mean()
const {
return (
float)
x; }
86 int max()
const {
return x; }
135 float sum()
const {
return x; }
137 float max()
const {
return x; }
190 float mean()
const {
return (
float)(
r +
g +
b) / 3; }
244 float mean()
const {
return (
r +
g +
b) / 3; }
257 #ifdef BEATMUP_CHANNEL_ORDER_ARGB
259 #elif BEATMUP_CHANNEL_ORDER_BGRA
311 float mean()
const {
return (
float)(
r +
g +
b +
a) / 4; }
324 #ifdef BEATMUP_CHANNEL_ORDER_ARGB
326 #elif BEATMUP_CHANNEL_ORDER_BGRA
392 return i > 0 ? (i < 255 ? i : 255) : 0;
399 return x > 0 ? (
x < 255 ?
x / 255.0f : 1.0f) : 0.0f;
406 return x > 0.0f ? (
x < 1.0f ?
x : 1.0f) : 0.0f;
413 return x > 0 ? (
x < 255 ?
x : 255) : 0;
433 float _ =
x / 255.0f;
438 float _ =
x / 255.0f;
451 x = (P.
r + P.
g + P.
b) / 3;
455 x = (P.
r + P.
g + P.
b) / 3;
496 return pixfloat3{
x / 255.0f + P.
r,
x / 255.0f + P.
g,
x / 255.0f + P.
b };
500 return pixfloat4(
x / 255.0f + P.
r,
x / 255.0f + P.
g,
x / 255.0f + P.
b, 1.0f + P.
a);
529 return pixfloat3{
x / 255.0f - P.
r,
x / 255.0f - P.
g,
x / 255.0f - P.
b };
533 return pixfloat4(
x / 255.0f - P.
r,
x / 255.0f - P.
g,
x / 255.0f - P.
b, 1.0f - P.
a);
562 return pixfloat3{
x * P.
r / 255.0f,
x * P.
g / 255.0f,
x * P.
b / 255.0f };
566 return pixfloat4(
x * P.
r / 255.0f,
x * P.
g / 255.0f,
x * P.
b / 255.0f, P.
a);
618 x = (P.
r + P.
g + P.
b) / 765.0f;
622 x = (P.
r + P.
g + P.
b) / 3;
626 x = (P.
r + P.
g + P.
b) / 765.0f;
630 x = (P.
r + P.
g + P.
b) / 3;
647 return pixfloat3{
x + P.
r / 255.0f,
x + P.
g / 255.0f,
x + P.
b / 255.0f };
651 return pixfloat4(
x + P.
r / 255.0f,
x + P.
g / 255.0f,
x + P.
b / 255.0f, 1.0f + P.
a / 255.0f);
680 return pixfloat3{
x - P.
r / 255.0f,
x - P.
g / 255.0f,
x - P.
b / 255.0f };
684 return pixfloat4(
x - P.
r / 255.0f,
x - P.
g / 255.0f,
x - P.
b / 255.0f, 1.0f - P.
a / 255.0f);
713 return pixfloat3{
x * P.
r / 255.0f,
x * P.
g / 255.0f,
x * P.
b / 255.0f };
717 return pixfloat4(
x * P.
r / 255.0f,
x * P.
g / 255.0f,
x * P.
b / 255.0f, P.
a / 255.0f);
763 return pixfloat4{
r / 255.0f,
g / 255.0f,
b / 255.0f, 1 };
767 return (
r == P.
r) && (
g == P.
g) && (
b == P.
b);
808 return pixfloat3{
r / 255.0f + P,
g / 255.0f + P,
b / 255.0f + P };
824 return pixfloat3{
r / 255.0f + P.
x,
g / 255.0f + P.
x,
b / 255.0f + P.
x };
828 return pixfloat3{
r / 255.0f + P.
r,
g / 255.0f + P.
g,
b / 255.0f + P.
b };
832 return pixfloat4(
r / 255.0f + P.
r,
g / 255.0f + P.
g,
b / 255.0f + P.
b, 1.0f + P.
a);
841 return pixfloat3{
r / 255.0f - P,
g / 255.0f - P,
b / 255.0f - P };
857 return pixfloat3{
r / 255.0f - P.
x,
g / 255.0f - P.
x,
b / 255.0f - P.
x };
861 return pixfloat3{
r / 255.0f - P.
r,
g / 255.0f - P.
g,
b / 255.0f - P.
b };
865 return pixfloat4(
r / 255.0f - P.
r,
g / 255.0f - P.
g,
b / 255.0f - P.
b, 1.0f - P.
a);
874 return pixfloat3{
r * P / 255.0f,
g * P / 255.0f,
b * P / 255.0f };
878 return pixint3{
r * P.
x / 255,
g * P.
x / 255,
b * P.
x / 255 };
882 return pixint3{
r * P.
r / 255,
g * P.
g / 255,
b * P.
b / 255 };
890 return pixfloat3{
r * P.
x / 255.0f,
g * P.
x / 255.0f,
b * P.
x / 255.0f };
894 return pixfloat3{
r * P.
r / 255.0f,
g * P.
g / 255.0f,
b * P.
b / 255.0f };
898 return pixfloat4(
r * P.
r / 255.0f,
g * P.
g / 255.0f,
b * P.
b / 255.0f, P.
a);
936 return (
r == P.
r) && (
g == P.
g) && (
b == P.
b);
940 r =
g =
b = P.
x / 255.0f;
986 return pixfloat3{
r + P.
r / 255.0f,
g + P.
g / 255.0f,
b + P.
b / 255.0f };
990 return pixfloat4(
r + P.
r / 255.0f,
g + P.
g / 255.0f,
b + P.
b / 255.0f, 1.0f + P.
a / 255.0f);
1020 return pixfloat3{
r - P.
r / 255.0f,
g - P.
g / 255.0f,
b - P.
b / 255.0f };
1024 return pixfloat4(
r - P.
r / 255.0f,
g - P.
g / 255.0f,
b - P.
b / 255.0f, 1.0f - P.
a / 255.0f);
1049 float f = P.
x / 255.0f;
1054 return pixfloat3{
r * P.
r / 255.0f,
g * P.
g / 255.0f,
b * P.
b / 255.0f };
1058 return pixfloat4(
r * P.
r / 255.0f,
g * P.
g / 255.0f,
b * P.
b / 255.0f, P.
a / 255.0f);
1100 return pixfloat3{
r / 255.0f,
g / 255.0f,
b / 255.0f };
1104 return pixfloat4{
r / 255.0f,
g / 255.0f,
b / 255.0f,
a / 255.0f };
1108 return (
r == P.
r) && (
g == P.
g) && (
b == P.
b) && (
a == P.
a);
1155 return pixfloat4(
r / 255.0f + P,
g / 255.0f + P,
b / 255.0f + P,
a / 255.0f + P);
1171 return pixfloat4(
r / 255.0f + P.
x,
g / 255.0f + P.
x,
b / 255.0f + P.
x,
a / 255.0f + 1.0f);
1175 return pixfloat4(
r / 255.0f + P.
r,
g / 255.0f + P.
g,
b / 255.0f + P.
b,
a / 255.0f + 1.0f);
1179 return pixfloat4(
r / 255.0f + P.
r,
g / 255.0f + P.
g,
b / 255.0f + P.
b,
a / 255.0f + P.
a);
1188 return pixfloat4(
r / 255.0f - P,
g / 255.0f - P,
b / 255.0f - P,
a / 255.0f - P);
1204 return pixfloat4(
r / 255.0f - P.
x,
g / 255.0f - P.
x,
b / 255.0f - P.
x,
a / 255.0f - 1.0f);
1208 return pixfloat4(
r / 255.0f - P.
r,
g / 255.0f - P.
g,
b / 255.0f - P.
b,
a / 255.0f - 1.0f);
1212 return pixfloat4(
r / 255.0f - P.
r,
g / 255.0f - P.
g,
b / 255.0f - P.
b,
a / 255.0f - P.
a);
1221 return pixfloat4(
r * P / 255.0f,
g * P / 255.0f,
b * P / 255.0f,
a * P / 255.0f);
1233 return pixint4(
r * P.
r / 255,
g * P.
g / 255,
b * P.
b / 255,
a * P.
a / 255);
1237 return pixfloat4(
r * P.
x / 255.0f,
g * P.
x / 255.0f,
b * P.
x / 255.0f,
a / 255.0f);
1241 return pixfloat4(
r * P.
r / 255.0f,
g * P.
g / 255.0f,
b * P.
b / 255.0f,
a / 255.0f);
1245 return pixfloat4(
r * P.
r / 255.0f,
g * P.
g / 255.0f,
b * P.
b / 255.0f,
a * P.
a / 255.0f);
1255 return pixfloat4(
r / 255.0f,
g / 255.0f,
b / 255.0f,
a / 255.0f);
1290 return (
r == P.
r) && (
g == P.
g) && (
b == P.
b) && (
a == P.
a);
1294 r =
g =
b = P.
x / 255.0f;
1346 return pixfloat4(
r + P.
r / 255.0f,
g + P.
g / 255.0f,
b + P.
b / 255.0f,
a + 1.0f);
1350 return pixfloat4(
r + P.
r / 255.0f,
g + P.
g / 255.0f,
b + P.
b / 255.0f,
a + P.
a / 255.0f);
1380 return pixfloat4(
r - P.
r / 255.0f,
g - P.
g / 255.0f,
b - P.
b / 255.0f,
a - 1.0f);
1384 return pixfloat4(
r - P.
r / 255.0f,
g - P.
g / 255.0f,
b - P.
b / 255.0f,
a - P.
a / 255.0f - 1.0f);
1409 float f = P.
x / 255.0f;
1418 return pixfloat4(
r * P.
r / 255.0f,
g * P.
g / 255.0f,
b * P.
b / 255.0f,
a * P.
a / 255.0f);
CustomPoint< numeric > operator-(const CustomPoint< numeric > &point)
Point with negative coordinates.
pixbyte clipPixint(int x)
Clips an integer pixel value to 0..255 range.
pixfloat clipPixfloat(pixfloat x)
Clips a floating point pixel value to 0..1 range.
pixbyte pixfloat2pixbyte(pixfloat x)
Converts a floating point pixel value to a 0..255 integer.
pixfloat int2pixfloat(int x)
Converts an integer value to 0..1 floating point pixel value.
CustomPoint< numeric > max(const CustomPoint< numeric > &a, const CustomPoint< numeric > &b)
Monochromatic floating point arithmetic.
bool operator==(const pixfloat1 P) const
pixfloat1 operator/(const int P) const
void operator=(const pixint1 P)
pixfloat1 operator+(const int P) const
pixfloat1 operator-(const int P) const
pixfloat1 operator*(const int P) const
pixfloat1 makeFloat() const
Trichromatic floating point arithmetic.
bool operator==(const pixfloat3 P) const
pixfloat3 operator-(const int P) const
pixfloat3 makeFloat() const
pixfloat3(const color3f &_)
pixfloat3 operator/(const int P) const
pixfloat3 operator*(const int P) const
pixfloat3 operator+(const int P) const
void operator=(const pixint1 P)
pixfloat3(float r, float g, float b)
4-channel floating point arithmetic
void operator=(const pixint1 P)
bool operator==(const pixfloat4 P) const
pixfloat & operator[](int i)
pixfloat4 operator*(const int P) const
pixfloat operator[](int i) const
pixfloat4 operator+(const int P) const
pixfloat4(const color4f &_)
pixfloat4 makeFloat() const
pixfloat4 operator/(const int P) const
pixfloat4 operator-(const int P) const
pixfloat4(float r, float g, float b, float a)
Monochromatic integer arithmetic.
pixint1 operator-(const int P) const
void operator=(const pixint1 P)
pixint1 operator/(const int P) const
pixint1 operator+(const int P) const
pixfloat1 makeFloat() const
pixint1 operator*(const int P) const
bool operator==(const pixint1 P) const
Trichromatic integer arithmetic.
pixint3 operator-(const int P) const
pixfloat3 makeFloat() const
bool operator==(const pixint3 P) const
void operator=(const pixint1 P)
pixint3 operator*(const int P) const
pixint3 operator+(const int P) const
pixint3(int r, int g, int b)
pixint3(const color3i &_)
pixint3 operator/(const int P) const
4-channel integer arithmetic
void operator=(const pixint1 P)
pixint4 operator-(const int P) const
static pixint4 fromColor(const color4i &_)
pixint4 operator/(const int P) const
pixint4(int r, int g, int b, int a)
bool operator==(const pixint4 P) const
pixint4 operator*(const int P) const
pixfloat4 makeFloat() const
pixint4 operator+(const int P) const
#define roundf_fast(X)
rounding (nearest integer)
jobject jlong jint jint jint jint g
jobject jlong jint jint jint jint jint b
jobject jlong jint jint jint r
jobject jlong jint jint jint jint jint jint a