21 #include "include/Beatmup_Bitmap.h"
22 #include "include/Beatmup_Android_ExternalBitmap.h"
23 #include "include/Beatmup_Rendering_Scene.h"
24 #include "include/Beatmup_Rendering_SceneRenderer.h"
25 #include "include/Beatmup_Shading_ImageShader.h"
26 #include "include/Beatmup_Shading_ShaderApplicator.h"
27 #include "include/Beatmup_Imaging_BinaryOperation.h"
28 #include "include/Beatmup_Imaging_ColorMatrix.h"
29 #include "include/Beatmup_Imaging_FloodFill.h"
30 #include "include/Beatmup_Imaging_Filters_PixelwiseFilter.h"
31 #include "include/Beatmup_Imaging_Filters_ColorMatrixTransform.h"
32 #include "include/Beatmup_Imaging_Filters_Sepia.h"
33 #include "include/Beatmup_Imaging_Resampler.h"
34 #include "include/Beatmup_Imaging_ColorMatrix.h"
132 for (
int i = 0; i <
n; i++) {
229 JNIMETHOD(
void, setLayerTransform, Java_Beatmup_Rendering_Scene, setLayerTransform)(JNIEnv *
jenv,
jobject,
jlong hLayer, jfloat
x, jfloat
y, jfloat
a11, jfloat
a12, jfloat
a21, jfloat
a22) {
314 JNIMETHOD(
void, setBitmapLayerModulationColor, Java_Beatmup_Rendering_Scene, setBitmapLayerModulationColor)(JNIEnv *
jenv,
jobject,
jlong hLayer, jfloat
r, jfloat
g, jfloat
b, jfloat
a) {
354 layer->getMaskMapping().matrix.skewDegrees((
float)
x, (
float)
y);
372 JNIMETHOD(
void, setBitmapLayerImageTransform, Java_Beatmup_Rendering_Scene, setBitmapLayerImageTransform)(JNIEnv *
jenv,
jobject,
jlong hLayer, jfloat
x, jfloat
y, jfloat
a11, jfloat
a12, jfloat
a21, jfloat
a22) {
389 JNIMETHOD(
void, setBitmapLayerMaskTransform, Java_Beatmup_Rendering_Scene, setBitmapLayerMaskTransform)(JNIEnv *
jenv,
jobject,
jlong hLayer, jfloat
x, jfloat
y, jfloat
a11, jfloat
a12, jfloat
a21, jfloat
a22) {
411 layer->setBitmap(
nullptr);
423 layer->setMask(
nullptr);
443 return (jfloat)
layer->getCornerRadius();
457 return (jfloat)
layer->getBorderWidth();
471 return (jfloat)
layer->getSlopeWidth();
653 JNIMETHOD(
void,
crop, Java_Beatmup_Bitmap,
crop)(JNIEnv *
jenv,
jobject,
jlong hInputBitmap,
jlong hOutputBitmap, jint
x1, jint
y1, jint
x2, jint
y2, jint
left, jint
top) {
664 input->getContext().performTask(
crop);
676 JNIMETHOD(
void, pullPixels, Java_Beatmup_Bitmap, pullPixels)
740 operation->setOutput(
bitmap);
754 operation->resetCrop();
758 JNIMETHOD(
void, setCrop, Java_Beatmup_Imaging_BinaryOperation, setCrop)(
763 operation->setCropSize(
w,
h);
770 JNIMETHOD(
void, getCrop, Java_Beatmup_Imaging_BinaryOperation, getCrop)(
803 floodFill->setOutput(
bitmap);
811 floodFill->setMaskPos(
p);
845 floodFill->setComputeContours(
flag == JNI_TRUE);
852 return (jint) floodFill->getContourCount();
860 return floodFill->getContour(
n).getPointCount();
876 float stepLength2 = step*step;
877 unsigned int fragmentLength2 = (unsigned int)(stepLength2 + 1);
878 Beatmup::IntPoint prev = contour.getPoint(0);
880 for (int n = 0; n < contour.getPointCount(); n++) {
881 p = contour.getPoint(n);
882 fragmentLength2 += (p - prev).hypot2();
883 if (fragmentLength2 >= stepLength2) {
890 if (fragmentLength2 > 0) {
924 return filter->setInput(input);
932 return filter->setOutput(output);
939 JNIMETHOD(
jlong, newColorMatrixTransform, Java_Beatmup_Imaging_Filters_ColorMatrixTransform, newColorMatrixTransform)(JNIEnv *
jenv,
jclass) {
949 filter->getMatrix() = *
mat;
957 *
mat = filter->getMatrix();
961 JNIMETHOD(
void, setCoefficients, Java_Beatmup_Imaging_Filters_ColorMatrixTransform, setCoefficients)
977 filter->setHSVCorrection((
float)
h, (
float)
s, (
float)
v);
994 filter->allowIntegerApproximations(
allow == JNI_TRUE);
1001 return (jboolean) filter->isIntegerApproximationsAllowed();
1030 resampler->setInput(input);
1040 resampler->setOutput(output);
1053 JNIMETHOD(jint, getMode, Java_Beatmup_Imaging_Resampler, getMode)
1058 return (jint)resampler->getMode();
1067 resampler->setCubicParameter((
float)
val);
1071 JNIMETHOD(jfloat, getCubicParameter, Java_Beatmup_Imaging_Resampler, getCubicParameter)
1076 return (jfloat)resampler->getCubicParameter();
1095 JNIMETHOD(
jlong, newColorMatrix__FFFFF, Java_Beatmup_Imaging_ColorMatrix, newColorMatrix__FFFFF)(JNIEnv *
jenv,
jclass, jfloat
r, jfloat
g, jfloat
b, jfloat
s, jfloat
v) {
1124 #ifdef BEATMUP_DEBUG
1125 Beatmup::DebugAssertion::check(
x >= 0 && x < 4 && y >= 0 &&
y < 4,
"Matrix element index out of range: %d %d",
x,
y);
1127 return (jfloat)
mat->elem[
x][
y];
1134 #ifdef BEATMUP_DEBUG
1135 Beatmup::DebugAssertion::check(
x >= 0 && x < 4 && y >= 0 &&
y < 4,
"Matrix element index out of range: %d %d",
x,
y);
1161 JNIMETHOD(jstring, getInputImageId, Java_Beatmup_Shading_ImageShader, getInputImageId)
1169 JNIMETHOD(jstring, getInputImageDeclType, Java_Beatmup_Shading_ImageShader, getInputImageDeclType)
1186 JNIMETHOD(
void, addSampler, Java_Beatmup_Shading_ShaderApplicator, addSampler)
1193 applicator->addSampler(
bitmap, uniformNameStr);
1209 applicator->setShader(shader);
void addJavaReference(JNIEnv *jenv, jobject jobj, const Beatmup::Object *bobj)
Creates new global reference on a Java object to avoid garbage collecting.
jobject getJavaReference(const Beatmup::Object *bobj) const
Returns a reference to the Java object which a given object depends on.
A very basic class for any image.
void zero()
Sets all the pixels to zero.
2x3 affine mapping containing a 2x2 matrix and a 2D point
void setCenterPosition(const Point &newPos)
Adjusts the mapping origin so that the center of the axes box matches a given point.
void scale(float factor, const Point &fixedPoint=Point::ZERO)
Scales the mapping around a given point in target domain.
void rotateDegrees(float angle, const Point &fixedPoint=Point::ZERO)
Rotates the mapping around a given point in target domain.
Wrapper of Android.Graphics.Bitmap object.
Image coming from a SurfaceTexture (Camera or video decoder)
A binary pixelwise operation on images.
Operation
Binary operation specification.
Resamples an image to a given resolution.
Mode
Resampling mode (algorithm) specification.
Basic class: task and memory management, any kind of static data.
A task to clip images on CPU.
void setOutput(AbstractBitmap *output)
void setOutputOrigin(IntPoint)
Sets top-left position of the clip rectangle in output bitmap.
void setCropRect(IntRectangle)
Sets crop rectangle in input bitmap.
void setInput(AbstractBitmap *input)
void setElements(float a11, float a12, float a21, float a22)
Sets matrix element values.
float getOrientationDegrees()
Returns first axis orientation in degrees.
Color matrix filter: applies mapping Ax + B at each pixel of a given image in RGBA space.
Base class for image filters processing a given bitmap in a pixelwise fashion.
Flood fill algorithm implementation.
BorderMorphology
Morphological postprocessing operation applied to discovered connected components.
A GLSL program to process images.
static const std::string INPUT_IMAGE_DECL_TYPE
A virtual input image type defined at shader compile time by ordinary texture or OES texture sampler ...
static const std::string INPUT_IMAGE_ID
Shader variable name referring to the input image.
A sequence of integer-valued 2D points.
int getPointCount() const
Bitmap whose memory is managed by the Beatmup engine.
const int getHeight() const
Height of the texture in pixels.
const int getWidth() const
Width of the texture in pixels.
const PixelFormat getPixelFormat() const
Pixel format of the bitmap.
AbstractTask rendering a Scene.
bool getOutputPixelsFetching() const
Reports whether the output bitmap pixels are automatically offloaded from GPU to CPU memory every tim...
void setScene(Scene *scene)
OutputMapping
Scene coordinates to output (screen or bitmap) pixel coordinates mapping.
void resetOutput()
Removes a bitmap from the renderer output, if any, and switches to on-screen rendering.
void setOutputPixelsFetching(bool fetch)
Specifies whether the output image data is pulled from GPU to CPU memory every time the rendering is ...
void setOutputMapping(const OutputMapping mapping)
Specifies the output mapping specifying how the scene coordinates [0,1]² are mapped to the output (sc...
void setOutput(AbstractBitmap *bitmap)
Attaches a bitmap to the renderer output.
void setBackgroundImage(AbstractBitmap *)
Sets an image to pave the background.
Scene::Layer * pickLayer(float x, float y, bool inPixels) const
Retrieves a scene layer visible at a given point, if any.
OutputMapping getOutputMapping() const
Retrieves the output mapping specifying how the scene coordinates [0,1]² are mapped to the output (sc...
int getOutputReferenceWidth() const
void setOutputReferenceWidth(int newWidth)
Sets a value overriding output width for elements that have their size in pixels, in order to render ...
Layer having an image to render.
Layer containing a bitmap and a mask applied to the bitmap when rendering.
Abstract scene layer having name, type, geometry and some content to display.
void setVisible(bool visible)
Sets layer visibility.
void setName(const char *name)
bool isVisible() const
Returns layer visibility flag.
const std::string & getName() const
bool isPhantom() const
Returns true if the layer is ignored when searching a layer by point.
AffineMapping & getMapping()
void setPhantom(bool phantom)
Makes/unmakes the layer "phantom".
Bitmap layer using another bitmap as a mask.
Bitmap layer using a custom shader.
Layer containing a bitmap and a parametric mask (shape)
An ordered set of layers representing a renderable content.
A task applying an image shader to a bitmap.
static void pullPixels(AbstractBitmap &bitmap)
Copies bitmap from GPU memory to RAM.
void setIntPoint(JNIEnv *jenv, const Beatmup::IntPoint &point, jobject jPoint)
jobject makeIntRectangle(JNIEnv *jenv, const Beatmup::IntRectangle)
Creates Java's IntRectangle object from Beatmup IntRectangle.
void setAffineMapping(JNIEnv *jenv, const Beatmup::AffineMapping &mapping, jobject jMapping)
void setColor(JNIEnv *jenv, const Beatmup::color4i &c, jobject jColor)
4-channel floating point arithmetic
#define BEATMUP_DELETE_REFERENCE(obj)
BeatmupJavaObjectPool $pool
return layer isPhantom() ? JNI_TRUE jlong jfloat jfloat jfloat a11
Beatmup::InternalBitmap * bitmap
jlong jint jint jint jint op1y
jlong jlong jint jint jint jint jint left
return(jlong) new Beatmup jlong jobject jMat
return layer isPhantom() ? JNI_TRUE jlong jfloat jfloat jfloat jfloat jfloat jfloat a22
floodFill setComputeContours(flag==JNI_TRUE)
return layer getInPixels() ? JNI_TRUE jlong jobject jShader
return(jlong) new Beatmup jlong hInstance
return() jlong(new Beatmup::Scene())
BEATMUP_REFERENCE(jLayer, newbie)
Beatmup::IntPoint outOrigin(left, top)
Beatmup::Scene::Layer * layer
Beatmup::Scene::Layer * newbie
floodFill setBorderPostprocessing((Beatmup::FloodFill::BorderMorphology) op, hold, release)
BEATMUP_CATCH({ return floodFill->getContour(n).getPointCount();})
jlong jlong jint jint jint x2
return renderer getOutputMapping()
operation setOperand2(bitmap)
renderer setOutputPixelsFetching(fetch==JNI_TRUE)
Beatmup::color3f preservedColor
jlong jlong jint jint jint jint y2
renderer setOutputReferenceWidth((int) width)
resampler setMode((Beatmup::BitmapResampler::Mode) mode)
renderer setOutputMapping((Beatmup::SceneRenderer::OutputMapping) mapping)
return(jlong) new Beatmup jlong hBitmap
return scene getLayerCount()
return(jlong) new Beatmup jlong jlong hInstFrom
jlong jobject jobject jobject op2Origin
jlong jlong jlong hResult
floodFill setSeeds(xyPtr, count)
jlong jfloat jfloat jfloat b
JNIEnv jlong jobject jOutput
jlong jint jint jint op1x
Beatmup::IntPoint p((int) x,(int) y)
jlong jint jint jint jint jint jint jint outx
jobject jint jint jint pixelFormat
return layer isPhantom() ? JNI_TRUE jlong jfloat jfloat jfloat jfloat jfloat a21
jlong jlong hOutputBitmap
filter setHSVCorrection((float) h,(float) s,(float) v)
JNIEnv jlong jfloat jfloat s
return(jlong) new Beatmup jlong jstring src
jlong jobject jobject jobject jobject outputOrigin
jlong jint jfloat jfloat release
filter setColorInversion(preservedColor,(float) s,(float) v)
jlong jobject jobject jSubscene
return $pool getJavaReference & scene(index)
return bitmap getHeight()
JNIEnv jlong jint jfloat bias
bitmap notifyUpdate(width, height)
Beatmup::AffineMapping & mapping
jlong jobject jInputBitmap
floodFill setTolerance((float) tolerance)
Beatmup::SceneRenderer * renderer
BEATMUP_OBJ(Beatmup::Scene, subscene, jSubscene)
return(jlong) new Beatmup jlong hInstTo
return layer isVisible() ? JNI_TRUE jlong jboolean phantom
return(jlong) new Beatmup jlong hInst
return layer isPhantom() ? JNI_TRUE jlong jfloat jfloat jfloat jfloat a12
BEATMUP_OBJ_OR_NULL(Beatmup::ImageShader, shader, jShader)
jlong jint jint jint jint jint jint op2y
Beatmup::IntRectangle rect(x1, y1, x2, y2)
resampler setCubicParameter((float) val)
jlong jobject jobject op1Origin
jlong jint jint jint jint jint jint jint jint outy
renderer setOutput(bitmap)
jlong jint jint jint jint jint op2x
operation setOperand1(bitmap)
jlong jobject jOutputBitmap
layer getMapping().setCenterPosition(Beatmup jlong jfloat jfloat fixx
JNIMETHOD(jlong, newScene, Java_Beatmup_Rendering_Scene, newScene)(JNIEnv *jenv
Creates new scene.
layer getMapping().setCenterPosition(Beatmup jlong jfloat factor
return renderer getOutputReferenceWidth()
shader setSourceCode(javaChar)
jlong jlong jint jint jint jint jint jint top
layer getMapping().setCenterPosition(Beatmup jlong jfloat jfloat jfloat fixy
operation setOperation((Beatmup::BitmapBinaryOperation::Operation) op)
return bitmap getPixelFormat()
JNIEnv jlong jfloat jfloat jfloat v