Code: Select all
case _Overlay: // B<128 ? (2*A*B/255) : 255-2*(255-A)*(255-B)/255
for ( x=0; x< merged.height; x++ ) {
for ( y=0; y< merged.width; y++ ) {
ColorRGBA A = *(pixels1);
ColorRGBA B = *(pixels2);
*pixels2 = ColorRGBA {
(byte) URANGE(0, OVERLAY(A.r,B.r), 255),
(byte) URANGE(0, OVERLAY(A.g,B.g), 255),
(byte) URANGE(0, OVERLAY(A.b,B.b), 255),
(byte) URANGE(0, OVERLAY(A.a,B.a), 255)
};
pixels1++; pixels2++;
}
pixels1 += L.source.stride - L.source.width;
pixels2 += merged.stride - merged.width;
}
Here's another sample:
Code: Select all
Bitmap genStatic( int w, int h, float n ) {
Bitmap out {};
int x,y;
out.Allocate(null,w,h,0,pixelFormatRGBA,false);
for( x=0; x<w; x++ )
for ( y=0; y<h; y++ ) {
byte c;
float f= (float) uniform();
if ( f>0.5 ) c=0;
else c=255;
G_Pixel(out,x,y, ColorRGBA { c, c, c, c });
}
return out;
}
inline void G_Pixel( Bitmap s, int x, int y, ColorRGBA c ) {
((ColorRGBA *)s.picture)[s.stride * y + x] = c;
}
inline void G_PixelRGBA( Bitmap s, int x, int y, int r, int g, int b, int a ) {
ColorRGBA c { (byte) r, (byte) b, (byte) g, (byte) a };
((ColorRGBA *)s.picture)[s.stride * y + x] = c;
}
inline void G_PixelRGB( Bitmap s, int x, int y, int r, int g, int b ) {
ColorRGBA c { (byte) r, (byte) g, (byte) b, 255 };
((ColorRGBA *)s.picture)[s.stride * y + x] = c;
}