Beatmup
wrapper_imag.cpp
Go to the documentation of this file.
1 /*
2  Beatmup image and signal processing library
3  Copyright (C) 2019, lnstadrum
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #include "wrapper.h"
20 
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"
35 
36 #include "android/context.h"
37 #include "android/bitmap.h"
39 
40 #include <core/color/matrix.h>
41 #include <core/context.h>
42 #include <core/contours/contours.h>
43 #include <core/exception.h>
46 #include <core/filters/sepia.h>
47 #include <core/geometry.h>
48 #include <core/gpu/swapper.h>
50 #include <core/bitmap/resampler.h>
51 #include <core/bitmap/crop.h>
52 #include <core/bitmap/operator.h>
53 #include <core/bitmap/tools.h>
55 #include <core/scene/renderer.h>
57 
58 /////////////////////////////////////////////////////////////////////////////////////////////
59 // SCENE
60 /////////////////////////////////////////////////////////////////////////////////////////////
61 
62 /**
63  Creates new scene
64 */
65 JNIMETHOD(jlong, newScene, Java_Beatmup_Rendering_Scene, newScene)(JNIEnv * jenv, jclass) {
67  return (jlong) (new Beatmup::Scene());
68 }
69 
70 
71 /**
72  Creates new layer containing a scene
73  */
74 JNIMETHOD(jlong, newSceneLayer, Java_Beatmup_Rendering_Scene, newSceneLayer)(JNIEnv * jenv, jobject, jlong hScene, jobject jLayer, jobject jSubscene) {
78  Beatmup::Scene::Layer* newbie = &scene->addScene(*subscene);
79  BEATMUP_REFERENCE(jLayer, newbie); // adding reference
80  return (jlong)(newbie);
81 }
82 
83 /**
84  Creates new bitmap layer in a given scene
85 */
86 JNIMETHOD(jlong, newBitmapLayer, Java_Beatmup_Rendering_Scene, newBitmapLayer)(JNIEnv * jenv, jobject, jlong hScene, jobject jLayer) {
89  Beatmup::Scene::Layer* newbie = &scene->newBitmapLayer();
90  BEATMUP_REFERENCE(jLayer, newbie); // adding reference
91  return (jlong)(newbie);
92 }
93 
94 /**
95  Creates new masked bitmap layer in a given scene
96 */
97 JNIMETHOD(jlong, newMaskedBitmapLayer, Java_Beatmup_Rendering_Scene, newMaskedBitmapLayer)(JNIEnv * jenv, jobject, jlong hScene, jobject jLayer) {
100  Beatmup::Scene::Layer* newbie = &scene->newMaskedBitmapLayer();
101  BEATMUP_REFERENCE(jLayer, newbie); // adding reference
102  return (jlong)(newbie);
103 }
104 
105 /**
106  Creates new shaped bitmap layer in a given scene
107  */
108 JNIMETHOD(jlong, newShapedBitmapLayer, Java_Beatmup_Rendering_Scene, newShapedBitmapLayer)(JNIEnv * jenv, jobject, jlong hScene, jobject jLayer) {
111  Beatmup::Scene::Layer* newbie = &scene->newShapedBitmapLayer();
112  BEATMUP_REFERENCE(jLayer, newbie); // adding reference
113  return (jlong)(newbie);
114 }
115 
116 
117 JNIMETHOD(jlong, newShadedBitmapLayer, Java_Beatmup_Rendering_Scene, newShadedBitmapLayer)(JNIEnv * jenv, jobject, jlong hScene, jobject jLayer) {
120  Beatmup::Scene::Layer* newbie = &scene->newShadedBitmapLayer();
121  BEATMUP_REFERENCE(jLayer, newbie); // adding reference
122  return (jlong)(newbie);
123 }
124 
125 /**
126  Removes global references
127 */
128 JNIMETHOD(void, deleteLayers, Java_Beatmup_Rendering_Scene, deleteLayers)(JNIEnv * jenv, jobject jScene) {
131  int n = scene->getLayerCount();
132  for (int i = 0; i < n; i++) {
133  Beatmup::Scene::Layer &l = scene->getLayer(i);
135  }
136 }
137 
138 /**
139  Returns number of layers
140 */
141 JNIMETHOD(jint, getLayerCount, Java_Beatmup_Rendering_Scene, getLayerCount)(JNIEnv * jenv, jobject, jlong hScene) {
144  return scene->getLayerCount();
145 }
146 
147 /**
148  Retrieves layer by its index
149 */
150 JNIMETHOD(jobject, getLayerByIndex, Java_Beatmup_Rendering_Scene, getLayerByIndex)(JNIEnv * jenv, jobject, jlong hScene, jint index) {
153  return $pool.getJavaReference(&scene->getLayer(index));
154 }
155 
156 /**
157  Retrieves a layer by name
158 */
159 JNIMETHOD(jobject, getLayerByName, Java_Beatmup_Rendering_Scene, getLayerByName)(JNIEnv * jenv, jobject, jlong hScene, jstring name) {
163  Beatmup::Scene::Layer* layer = scene->getLayer(nameStr.c_str());
164  if (!layer)
165  return NULL;
167 }
168 
169 
170 JNIMETHOD(jobject, getLayerAtPoint, Java_Beatmup_Rendering_Scene, getLayerAtPoint)(JNIEnv * jenv, jobject, jlong hScene, jfloat x, jfloat y) {
173  Beatmup::Scene::Layer* layer = scene->getLayer(x, y);
174  if (!layer)
175  return NULL;
176  return $pool.getJavaReference(layer);
177 }
178 
179 /**
180  Renames given layer
181 */
182 JNIMETHOD(void, setLayerName, Java_Beatmup_Rendering_Scene, setLayerName)(JNIEnv * jenv, jobject, jlong hLayer, jstring name) {
186  layer->setName(nameStr.c_str());
187 }
188 
189 /**
190  Returns layer name
191 */
192 JNIMETHOD(jstring, getLayerName, Java_Beatmup_Rendering_Scene, getLayerName)(JNIEnv * jenv, jobject, jlong hLayer) {
195  return jenv->NewStringUTF(layer->getName().c_str());
196 }
197 
198 
199 JNIMETHOD(void, setLayerVisibility, Java_Beatmup_Rendering_Scene, setLayerVisibility)(JNIEnv * jenv, jobject, jlong hLayer, jboolean visible) {
202  layer->setVisible(visible == JNI_TRUE);
203 }
204 
205 
206 JNIMETHOD(jboolean, getLayerVisibility, Java_Beatmup_Rendering_Scene, getLayerVisibility)(JNIEnv * jenv, jobject, jlong hLayer) {
209  return layer->isVisible() ? JNI_TRUE : JNI_FALSE;
210 }
211 
212 /**
213  Phantom layer mode management
214 */
215 JNIMETHOD(void, setLayerPhantomFlag, Java_Beatmup_Rendering_Scene, setLayerPhantomFlag)(JNIEnv * jenv, jobject, jlong hLayer, jboolean phantom) {
218  layer->setPhantom(phantom == JNI_TRUE);
219 }
220 
221 
222 JNIMETHOD(jboolean, getLayerPhantomFlag, Java_Beatmup_Rendering_Scene, getLayerPhantomFlag)(JNIEnv * jenv, jobject, jlong hLayer) {
225  return layer->isPhantom() ? JNI_TRUE : JNI_FALSE;
226 }
227 
228 
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) {
233  mapping.position.x = x;
234  mapping.position.y = y;
235  mapping.matrix.setElements((float)a11, (float)a12, (float)a21, (float)a22);
236 }
237 
238 
239 JNIMETHOD(void, getLayerTransform, Java_Beatmup_Rendering_Scene, getLayerTransform)(JNIEnv * jenv, jobject, jlong hLayer, jobject mapping) {
243 }
244 
245 /**
246  Changes layer horizontal position
247 */
248 JNIMETHOD(void, setLayerX, Java_Beatmup_Rendering_Scene, setLayerX)(JNIEnv * jenv, jobject, jlong hLayer, jfloat x) {
251  layer->getMapping().position.x = x;
252 }
253 
254 /**
255  Returns layer horizontal position
256 */
257 JNIMETHOD(jfloat, getLayerX, Java_Beatmup_Rendering_Scene, getLayerX)(JNIEnv * jenv, jobject, jlong hLayer) {
260  return layer->getMapping().position.x;
261 }
262 
263 /**
264  Changes layer vertical position
265 */
266 JNIMETHOD(void, setLayerY, Java_Beatmup_Rendering_Scene, setLayerY)(JNIEnv * jenv, jobject, jlong hLayer, jfloat y) {
269  layer->getMapping().position.y = y;
270 }
271 
272 /**
273  Returns layer vertical position
274 */
275 JNIMETHOD(jfloat, getLayerY, Java_Beatmup_Rendering_Scene, getLayerY)(JNIEnv * jenv, jobject, jlong hLayer) {
278  return layer->getMapping().position.y;
279 }
280 
281 /**
282  Returns layer orientation in degrees
283 */
284 JNIMETHOD(jfloat, getLayerOrientation, Java_Beatmup_Rendering_Scene, getLayerOrientation)(JNIEnv * jenv, jobject, jlong hLayer) {
288 }
289 
290 /**
291  Sets layer center position
292 */
293 JNIMETHOD(void, setLayerCenterPos, Java_Beatmup_Rendering_Scene, setLayerCenterPos)(JNIEnv * jenv, jobject, jlong hLayer, jfloat x, jfloat y) {
297 }
298 
299 
300 JNIMETHOD(void, scaleLayer, Java_Beatmup_Rendering_Scene, scaleLayer)(JNIEnv * jenv, jobject, jlong hLayer, jfloat factor, jfloat fixx, jfloat fixy) {
304 }
305 
306 
307 JNIMETHOD(void, rotateLayer, Java_Beatmup_Rendering_Scene, rotateLayer)(JNIEnv * jenv, jobject, jlong hLayer, jfloat a, jfloat fixx, jfloat fixy) {
311 }
312 
313 
314 JNIMETHOD(void, setBitmapLayerModulationColor, Java_Beatmup_Rendering_Scene, setBitmapLayerModulationColor)(JNIEnv * jenv, jobject, jlong hLayer, jfloat r, jfloat g, jfloat b, jfloat a) {
317  layer->setModulationColor(Beatmup::pixfloat4(r, g, b, a));
318 }
319 
320 
321 JNIMETHOD(void, getBitmapLayerModulationColor, Java_Beatmup_Rendering_Scene, getBitmapLayerModulationColor)(JNIEnv * jenv, jobject, jlong hLayer, jobject jColor) {
324  $pool.factory.setColor(jenv, layer->getModulationColor(), jColor);
325 }
326 
327 
328 JNIMETHOD(void, setBitmapLayerMaskPos, Java_Beatmup_Rendering_Scene, setBitmapLayerMaskPos)(JNIEnv * jenv, jobject, jlong hLayer, jfloat x, jfloat y) {
331  Beatmup::AffineMapping& mapping = layer->getMaskMapping();
332  mapping.position.x = (float)x;
333  mapping.position.y = (float)y;
334 }
335 
336 
337 JNIMETHOD(void, scaleBitmapLayerMask, Java_Beatmup_Rendering_Scene, scaleBitmapLayerMask)(JNIEnv * jenv, jobject, jlong hLayer, jfloat factor, jfloat fixx, jfloat fixy) {
340  layer->getMaskMapping().scale((float)factor, Beatmup::Point((float)fixx,(float)fixy));
341 }
342 
343 
344 JNIMETHOD(void, rotateBitmapLayerMask, Java_Beatmup_Rendering_Scene, rotateBitmapLayerMask)(JNIEnv * jenv, jobject, jlong hLayer, jfloat a, jfloat fixx, jfloat fixy) {
347  layer->getMaskMapping().rotateDegrees((float)a, Beatmup::Point((float)fixx, (float)fixy));
348 }
349 
350 
351 JNIMETHOD(void, skewBitmapLayerMask, Java_Beatmup_Rendering_Scene, skewBitmapLayerMask)(JNIEnv * jenv, jobject, jlong hLayer, jfloat x, jfloat y) {
354  layer->getMaskMapping().matrix.skewDegrees((float)x, (float)y);
355 }
356 
357 
358 JNIMETHOD(void, setBitmapLayerBgColor, Java_Beatmup_Rendering_Scene, setBitmapLayerBgColor)(JNIEnv * jenv, jobject, jlong hLayer, jfloat r, jfloat g, jfloat b, jfloat a) {
361  layer->setBackgroundColor(Beatmup::pixfloat4(r, g, b, a));
362 }
363 
364 
365 JNIMETHOD(void, getBitmapLayerBgColor, Java_Beatmup_Rendering_Scene, getBitmapLayerBgColor)(JNIEnv * jenv, jobject, jlong hLayer, jobject jColor) {
368  $pool.factory.setColor(jenv, layer->getBackgroundColor(), jColor);
369 }
370 
371 
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) {
375  Beatmup::AffineMapping& mapping = layer->getBitmapMapping();
376  mapping.position.x = x;
377  mapping.position.y = y;
378  mapping.matrix.setElements((float)a11, (float)a12, (float)a21, (float)a22);
379 }
380 
381 
382 JNIMETHOD(void, getBitmapLayerImageTransform, Java_Beatmup_Rendering_Scene, getBitmapLayerImageTransform)(JNIEnv * jenv, jobject, jlong hLayer, jobject mapping) {
385  $pool.factory.setAffineMapping(jenv, layer->getBitmapMapping(), mapping);
386 }
387 
388 
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) {
392  Beatmup::AffineMapping& mapping = layer->getMaskMapping();
393  mapping.position.x = x;
394  mapping.position.y = y;
395  mapping.matrix.setElements((float)a11, (float)a12, (float)a21, (float)a22);
396 }
397 
398 
399 JNIMETHOD(void, getBitmapLayerMaskTransform, Java_Beatmup_Rendering_Scene, getBitmapLayerMaskTransform)(JNIEnv * jenv, jobject, jlong hLayer, jobject mapping) {
402  $pool.factory.setAffineMapping(jenv, layer->getMaskMapping(), mapping);
403 }
404 
405 
406 JNIMETHOD(void, setBitmapLayerBitmap, Java_Beatmup_Rendering_Scene, setBitmapLayerBitmap)(JNIEnv * jenv, jobject, jlong hLayer, jobject jBitmap) {
409  // deleting a global reference if layer has already a bitmap
410  if (!jBitmap)
411  layer->setBitmap(nullptr);
412  else {
413  // creating global reference and setting new bitmap
415  layer->setBitmap(bitmap);
416  }
417 }
418 
419 JNIMETHOD(void, setMaskedBitmapLayerMask, Java_Beatmup_Rendering_Scene, setMaskedBitmapLayerMask)(JNIEnv * jenv, jobject, jlong hLayer, jobject jMask) {
422  if (!jMask)
423  layer->setMask(nullptr);
424  else {
426  layer->setMask(mask);
427  }
428 }
429 
430 /**
431  Sets shaped bitmap mask corners radius
432  */
433 JNIMETHOD(void, setShapedBitmapLayerCornerRadius, Java_Beatmup_Rendering_Scene, setShapedBitmapLayerCornerRadius)(JNIEnv * jenv, jobject, jlong hLayer, jfloat radius) {
436  layer->setCornerRadius((float) radius);
437 }
438 
439 
440 JNIMETHOD(jfloat, getShapedBitmapLayerCornerRadius, Java_Beatmup_Rendering_Scene, getShapedBitmapLayerCornerRadius)(JNIEnv * jenv, jobject, jlong hLayer) {
443  return (jfloat)layer->getCornerRadius();
444 }
445 
446 
447 JNIMETHOD(void, setShapedBitmapLayerBorderWidth, Java_Beatmup_Rendering_Scene, setShapedBitmapLayerBorderWidth)(JNIEnv * jenv, jobject, jlong hLayer, jfloat width) {
450  layer->setBorderWidth((float) width);
451 }
452 
453 
454 JNIMETHOD(jfloat, getShapedBitmapLayerBorderWidth, Java_Beatmup_Rendering_Scene, getShapedBitmapLayerBorderWidth)(JNIEnv * jenv, jobject, jlong hLayer) {
457  return (jfloat) layer->getBorderWidth();
458 }
459 
460 
461 JNIMETHOD(void, setShapedBitmapLayerSlopeWidth, Java_Beatmup_Rendering_Scene, setShapedBitmapLayerSlopeWidth)(JNIEnv * jenv, jobject, jlong hLayer, jfloat width) {
464  layer->setSlopeWidth((float) width);
465 }
466 
467 
468 JNIMETHOD(jfloat, getShapedBitmapLayerSlopeWidth, Java_Beatmup_Rendering_Scene, getShapedBitmapLayerSlopeWidth)(JNIEnv * jenv, jobject, jlong hLayer) {
471  return (jfloat) layer->getSlopeWidth();
472 }
473 
474 
475 JNIMETHOD(void, setShapedBitmapLayerInPixelsSwitch, Java_Beatmup_Rendering_Scene, setShapedBitmapLayerInPixelsSwitch)(JNIEnv * jenv, jobject, jlong hLayer, jboolean inPixels) {
478  layer->setInPixels(inPixels == JNI_TRUE);
479 }
480 
481 
482 JNIMETHOD(jboolean, getShapedBitmapLayerInPixelsSwitch, Java_Beatmup_Rendering_Scene, getShapedBitmapLayerInPixelsSwitch)(JNIEnv * jenv, jobject, jlong hLayer) {
485  return layer->getInPixels() ? JNI_TRUE : JNI_FALSE;
486 }
487 
488 
489 JNIMETHOD(void, setShadedBitmapLayerShader, Java_Beatmup_Rendering_Scene, setShadedBitmapLayerShader)(JNIEnv * jenv, jobject, jlong hLayer, jobject jShader) {
493  layer->setShader(shader);
494 }
495 
496 /////////////////////////////////////////////////////////////////////////////////////////////
497 // SCENE RENDERER
498 /////////////////////////////////////////////////////////////////////////////////////////////
499 
500 JNIMETHOD(jlong, newSceneRenderer, Java_Beatmup_Rendering_SceneRenderer, newSceneRenderer)(JNIEnv * jenv, jclass, jobject jEnv) {
504  return (jlong)renderer;
505 }
506 
507 
508 JNIMETHOD(void, setOutput, Java_Beatmup_Rendering_SceneRenderer, setOutput)(JNIEnv * jenv, jobject, jlong hRenderer, jobject jBitmap) {
513 }
514 
515 
516 JNIMETHOD(void, resetOutput, Java_Beatmup_Rendering_SceneRenderer, resetOutput)(JNIEnv * jenv, jobject, jlong hRenderer) {
520 }
521 
522 JNIMETHOD(void, setScene, Java_Beatmup_Rendering_SceneRenderer, setScene)
524 {
529 }
530 
531 
532 JNIMETHOD(void, setOutputMapping, Java_Beatmup_Rendering_SceneRenderer, setOutputMapping)(JNIEnv * jenv, jobject, jlong hRenderer, jint mapping) {
536 }
537 
538 
539 JNIMETHOD(jint, getOutputMapping, Java_Beatmup_Rendering_SceneRenderer, getOutputMapping)(JNIEnv * jenv, jobject, jlong hRenderer) {
543 }
544 
545 
546 JNIMETHOD(void, setOutputReferenceWidth, Java_Beatmup_Rendering_SceneRenderer, setOutputReferenceWidth)(JNIEnv * jenv, jobject, jlong hRenderer, jint width) {
550 }
551 
552 
554  Java_Beatmup_Rendering_SceneRenderer, getOutputReferenceWidth)(JNIEnv * jenv, jobject, jlong hRenderer) {
558 }
559 
560 
561 JNIMETHOD(void, setOutputPixelsFetching, Java_Beatmup_Rendering_SceneRenderer, setOutputPixelsFetching)(JNIEnv * jenv, jobject, jlong hRenderer, jboolean fetch) {
565 }
566 
567 
568 JNIMETHOD(jboolean, getOutputPixelsFetching, Java_Beatmup_Rendering_SceneRenderer, getOutputPixelsFetching)(JNIEnv * jenv, jobject, jlong hRenderer) {
571  return renderer->getOutputPixelsFetching() ? JNI_TRUE : JNI_FALSE;
572 }
573 
574 
575 JNIMETHOD(void, setBackgroundBitmap, Java_Beatmup_Rendering_SceneRenderer, setBackgroundBitmap)(JNIEnv * jenv, jobject, jlong hRenderer, jobject jBitmap) {
580 }
581 
582 
583 JNIMETHOD(jobject, pickLayer, Java_Beatmup_Rendering_SceneRenderer, pickLayer)(JNIEnv * jenv, jobject, jlong hRenderer, jfloat x, jfloat y, jboolean inPixels) {
587  if (!layer)
588  return nullptr;
589  return $pool.getJavaReference(layer);
590 }
591 
592 /////////////////////////////////////////////////////////////////////////////////////////////
593 // BITMAP
594 /////////////////////////////////////////////////////////////////////////////////////////////
595 
596 /**
597  Creates new internally managed bitmap
598 */
599 JNIMETHOD(jlong, newInternalBitmap, Java_Beatmup_Bitmap, newInternalBitmap)(JNIEnv * jenv, jclass, jobject jCtx, jint width, jint height, jint pixelFormat) {
603  // ctx is used in internal bitmap destructor, so add an internal ref
605  return (jlong) bitmap;
606 }
607 
608 /**
609  Creates new bitmap from Android bitmap object
610 */
611 JNIMETHOD(jlong, newNativeBitmap, Java_Beatmup_Bitmap, newNativeBitmap)(JNIEnv * jenv, jclass, jobject jCtx, jobject bitmap) {
614  return (jlong) new Beatmup::Android::Bitmap(*ctx, jenv, bitmap);
615 }
616 
617 
618 /**
619  Returns bitmap width in pixels
620 */
621 JNIMETHOD(jint, getWidth, Java_Beatmup_Bitmap, getWidth)(JNIEnv * jenv, jobject, jlong hBitmap) {
624  return bitmap->getWidth();
625 }
626 
627 /**
628  Returns bitmap height in pixels
629 */
630 JNIMETHOD(jint, getHeight, Java_Beatmup_Bitmap, getHeight)(JNIEnv * jenv, jobject, jlong hBitmap) {
633  return bitmap->getHeight();
634 }
635 
636 /**
637  Returns bitmap pixel format
638 */
639 JNIMETHOD(jint, getPixelFormat, Java_Beatmup_Bitmap, getPixelFormat)(JNIEnv * jenv, jobject, jlong hBitmap) {
643 }
644 
645 
646 JNIMETHOD(void, zero, Java_Beatmup_Bitmap, zero)(JNIEnv * jenv, jobject, jlong hBitmap) {
650 }
651 
652 
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) {
660  crop.setInput(input);
661  crop.setOutput(output);
664  input->getContext().performTask(crop);
665 }
666 
667 
668 JNIMETHOD(void, invert, Java_Beatmup_Bitmap, invert)(JNIEnv * jenv, jclass, jlong hBitmap)
669 {
673 }
674 
675 
676 JNIMETHOD(void, pullPixels, Java_Beatmup_Bitmap, pullPixels)
677  (JNIEnv * jenv, jclass, jlong hBitmap)
678 {
682 }
683 
684 /////////////////////////////////////////////////////////////////////////////////////////////
685 // EXTERNAL BITMAP
686 /////////////////////////////////////////////////////////////////////////////////////////////
687 
688 JNIMETHOD(jlong, newExternalImage, Java_Beatmup_Android_ExternalBitmap, newExternalImage)(JNIEnv *jenv, jclass, jobject jCtx) {
692  // ctx is used in internal bitmap destructor, so add an internal ref
694  return (jlong) bitmap;
695 }
696 
697 
698 JNIMETHOD(void, bind, Java_Beatmup_Android_ExternalBitmap, bind)(JNIEnv * jenv, jobject jobj, jlong hBitmap) {
700  bitmap->bind(jenv, jobj);
701 }
702 
703 
704 JNIMETHOD(void, notifyUpdate, Java_Beatmup_Android_ExternalBitmap, notifyUpdate)(JNIEnv * jenv, jobject, jlong hBitmap, jint width, jint height) {
707  bitmap->notifyUpdate(width, height);
708 }
709 
710 /////////////////////////////////////////////////////////////////////////////////////////////
711 // BINARY OPERATION
712 /////////////////////////////////////////////////////////////////////////////////////////////
713 
714 JNIMETHOD(jlong, newBinaryOperation, Java_Beatmup_Imaging_BinaryOperation, newBinaryOperation)(JNIEnv * jenv, jclass) {
716  return (jlong) new Beatmup::BitmapBinaryOperation();
717 }
718 
719 
720 JNIMETHOD(void, setOperand1, Java_Beatmup_Imaging_BinaryOperation, setOperand1)(JNIEnv * jenv, jobject, jlong hInstance, jobject jBitmap) {
724  operation->setOperand1(bitmap);
725 }
726 
727 
728 JNIMETHOD(void, setOperand2, Java_Beatmup_Imaging_BinaryOperation, setOperand2)(JNIEnv * jenv, jobject, jlong hInstance, jobject jBitmap) {
732  operation->setOperand2(bitmap);
733 }
734 
735 
736 JNIMETHOD(void, setOutput, Java_Beatmup_Imaging_BinaryOperation, setOutput)(JNIEnv * jenv, jobject, jlong hInstance, jobject jBitmap) {
740  operation->setOutput(bitmap);
741 }
742 
743 
744 JNIMETHOD(void, setOperation, Java_Beatmup_Imaging_BinaryOperation, setOperation)(JNIEnv * jenv, jobject, jlong hInstance, jint op) {
748 }
749 
750 
751 JNIMETHOD(void, resetCrop, Java_Beatmup_Imaging_BinaryOperation, resetCrop)(JNIEnv * jenv, jobject, jlong hInstance) {
754  operation->resetCrop();
755 }
756 
757 
758 JNIMETHOD(void, setCrop, Java_Beatmup_Imaging_BinaryOperation, setCrop)(
759  JNIEnv * jenv, jobject, jlong hInstance,
760  jint w, jint h, jint op1x, jint op1y, jint op2x, jint op2y, jint outx, jint outy) {
763  operation->setCropSize(w, h);
764  operation->setOp1Origin(Beatmup::IntPoint(op1x, op1y));
765  operation->setOp2Origin(Beatmup::IntPoint(op2x, op2y));
766  operation->setOutputOrigin(Beatmup::IntPoint(outx, outy));
767 }
768 
769 
770 JNIMETHOD(void, getCrop, Java_Beatmup_Imaging_BinaryOperation, getCrop)(
771  JNIEnv * jenv, jobject,
775  $pool.factory.setIntPoint(jenv, operation->getCropWidth(), operation->getCropHeight(), size);
776  $pool.factory.setIntPoint(jenv, operation->getOp1Origin(), op1Origin);
777  $pool.factory.setIntPoint(jenv, operation->getOp2Origin(), op2Origin);
778  $pool.factory.setIntPoint(jenv, operation->getOutputOrigin(), outputOrigin);
779 }
780 
781 /////////////////////////////////////////////////////////////////////////////////////////////
782 // FLOOD FILL
783 /////////////////////////////////////////////////////////////////////////////////////////////
784 
785 JNIMETHOD(jlong, newFloodFill, Java_Beatmup_Imaging_FloodFill, newFloodFill)(JNIEnv * jenv, jclass) {
787  return (jlong) new Beatmup::FloodFill();
788 }
789 
790 
791 JNIMETHOD(void, setInput, Java_Beatmup_Imaging_FloodFill, setInput)(JNIEnv * jenv, jobject, jlong hInstance, jobject jBitmap) {
795  floodFill->setInput(bitmap);
796 }
797 
798 
799 JNIMETHOD(void, setOutput, Java_Beatmup_Imaging_FloodFill, setOutput)(JNIEnv * jenv, jobject, jlong hInstance, jobject jBitmap) {
803  floodFill->setOutput(bitmap);
804 }
805 
806 
807 JNIMETHOD(void, setMaskPos, Java_Beatmup_Imaging_FloodFill, setMaskPos)(JNIEnv * jenv, jobject, jlong hInstance, jint x, jint y) {
810  Beatmup::IntPoint p((int)x, (int)y);
811  floodFill->setMaskPos(p);
812 }
813 
814 
815 JNIMETHOD(void, setTolerance, Java_Beatmup_Imaging_FloodFill, setTolerance)(JNIEnv * jenv, jobject, jlong hInstance, jfloat tolerance) {
818  floodFill->setTolerance((float) tolerance);
819 }
820 
821 
822 JNIMETHOD(void, setBorderPostprocessing, Java_Beatmup_Imaging_FloodFill, setBorderPostprocessing)(JNIEnv * jenv, jobject, jlong hInstance, jint op, jfloat hold, jfloat release) {
825  floodFill->setBorderPostprocessing((Beatmup::FloodFill::BorderMorphology)op, hold, release);
826 }
827 
828 
829 JNIMETHOD(void, setSeeds, Java_Beatmup_Imaging_FloodFill, setSeeds)(JNIEnv * jenv, jobject, jlong hInstance, jintArray xy) {
832  jint* xyPtr = jenv->GetIntArrayElements(xy, NULL);
833  int count = (int)jenv->GetArrayLength(xy) / 2;
834  floodFill->setSeeds(xyPtr, count);
835  jenv->ReleaseIntArrayElements(xy, xyPtr, JNI_ABORT);
836 }
837 
838 
839 /**
840  Enables / disables border contours computation
841  */
842 JNIMETHOD(void, setComputeContours, Java_Beatmup_Imaging_FloodFill, setComputeContours)(JNIEnv * jenv, jobject, jlong hInstance, jboolean flag) {
845  floodFill->setComputeContours(flag == JNI_TRUE);
846 }
847 
848 
849 JNIMETHOD(jint, getContourCount, Java_Beatmup_Imaging_FloodFill, getContourCount)(JNIEnv * jenv, jobject, jlong hInstance) {
852  return (jint) floodFill->getContourCount();
853 }
854 
855 
856 JNIMETHOD(jint, getContourPointCount, Java_Beatmup_Imaging_FloodFill, getContourPointCount)(JNIEnv * jenv, jobject, jlong hInstance, jint n) {
860  return floodFill->getContour(n).getPointCount();
861  });
862  return 0;
863 }
864 
865 
866 /**
867  Returns a layer border component (a contour)
868 */
869 JNIMETHOD(jintArray, getContour, Java_Beatmup_Imaging_FloodFill, getContour)(JNIEnv * jenv, jobject, jlong hInstance, jint index, jfloat step) {
870  std::vector<int> xy;
874  const Beatmup::IntegerContour2D& contour = floodFill->getContour(index);
875  if (contour.getPointCount() > 0) {
876  float stepLength2 = step*step;
877  unsigned int fragmentLength2 = (unsigned int)(stepLength2 + 1);
878  Beatmup::IntPoint prev = contour.getPoint(0);
879  Beatmup::IntPoint p;
880  for (int n = 0; n < contour.getPointCount(); n++) {
881  p = contour.getPoint(n);
882  fragmentLength2 += (p - prev).hypot2();
883  if (fragmentLength2 >= stepLength2) {
884  xy.push_back(p.x);
885  xy.push_back(p.y);
886  fragmentLength2 = 0;
887  }
888  prev = p;
889  }
890  if (fragmentLength2 > 0) {
891  xy.push_back(p.x);
892  xy.push_back(p.y);
893  }
894  }
895  });
896  // copying to java
897  jintArray result = jenv->NewIntArray(xy.size());
898  jint *javaxy = jenv->GetIntArrayElements(result, NULL);
899  int pn = 0;
900  for (auto e : xy)
901  javaxy[pn++] = e;
902  jenv->ReleaseIntArrayElements(result, javaxy, 0);
903  return result;
904 }
905 
906 
907 /**
908  * Returns mask bounding box
909  */
910 JNIMETHOD(jobject, getBoundingBox, Java_Beatmup_Imaging_FloodFill, getBoundingBox)(JNIEnv * jenv, jobject, jlong hInstance) {
913  return $pool.factory.makeIntRectangle(jenv, floodFill->getBounds());
914 }
915 
916 /////////////////////////////////////////////////////////////////////////////////////////////
917 // PIXELWISE FILTER
918 /////////////////////////////////////////////////////////////////////////////////////////////
919 
920 JNIMETHOD(void, setBitmaps, Java_Beatmup_Imaging_Filters_PixelwiseFilter, setInput)(JNIEnv * jenv, jobject, jlong hInstance, jobject jInputBitmap) {
924  return filter->setInput(input);
925 }
926 
927 
928 JNIMETHOD(void, setBitmaps, Java_Beatmup_Imaging_Filters_PixelwiseFilter, setOutput)(JNIEnv * jenv, jobject, jlong hInstance, jobject jOutputBitmap) {
932  return filter->setOutput(output);
933 }
934 
935 /////////////////////////////////////////////////////////////////////////////////////////////
936 // COLOR MATRIX TRANSFORM
937 /////////////////////////////////////////////////////////////////////////////////////////////
938 
939 JNIMETHOD(jlong, newColorMatrixTransform, Java_Beatmup_Imaging_Filters_ColorMatrixTransform, newColorMatrixTransform)(JNIEnv * jenv, jclass) {
941  return (jlong) new Beatmup::Filters::ColorMatrix();
942 }
943 
944 
945 JNIMETHOD(void, setFromMatrix, Java_Beatmup_Imaging_Filters_ColorMatrixTransform, setFromMatrix)(JNIEnv * jenv, jobject, jlong hInst, jobject jMat) {
949  filter->getMatrix() = *mat;
950 }
951 
952 
953 JNIMETHOD(void, assignToMatrix, Java_Beatmup_Imaging_Filters_ColorMatrixTransform, assignToMatrix)(JNIEnv * jenv, jobject, jlong hInst, jobject jMat) {
957  *mat = filter->getMatrix();
958 }
959 
960 
961 JNIMETHOD(void, setCoefficients, Java_Beatmup_Imaging_Filters_ColorMatrixTransform, setCoefficients)
962  (JNIEnv * jenv, jobject, jlong hInstance, jint out, jfloat bias, jfloat r, jfloat g, jfloat b, jfloat a)
963 {
967  filter->setCoefficients(out, bias, r, g, b, a);
968  });
969 }
970 
971 
972 JNIMETHOD(void, setHSVCorrection, Java_Beatmup_Imaging_Filters_ColorMatrixTransform, setHSVCorrection)
973  (JNIEnv * jenv, jobject, jlong hInstance, jfloat h, jfloat s, jfloat v)
974 {
977  filter->setHSVCorrection((float)h, (float)s, (float)v);
978 }
979 
980 
981 JNIMETHOD(void, setColorInversion, Java_Beatmup_Imaging_Filters_ColorMatrixTransform, setColorInversion)
982  (JNIEnv * jenv, jobject, jlong hInstance, jfloat r, jfloat g, jfloat b, jfloat s, jfloat v)
983 {
986  Beatmup::color3f preservedColor{ (float)r, (float)g, (float)b };
987  filter->setColorInversion(preservedColor, (float)s, (float)v);
988 }
989 
990 
991 JNIMETHOD(void, setAllowIntegerApprox, Java_Beatmup_Imaging_Filters_ColorMatrixTransform, setAllowIntegerApprox)(JNIEnv * jenv, jobject, jlong hInstance, jboolean allow) {
994  filter->allowIntegerApproximations(allow == JNI_TRUE);
995 }
996 
997 
998 JNIMETHOD(jboolean, allowIntegerApprox, Java_Beatmup_Imaging_Filters_ColorMatrixTransform, allowIntegerApprox)(JNIEnv * jenv, jobject, jlong hInstance) {
1001  return (jboolean) filter->isIntegerApproximationsAllowed();
1002 }
1003 
1004 /////////////////////////////////////////////////////////////////////////////////////////////
1005 // SEPIA
1006 /////////////////////////////////////////////////////////////////////////////////////////////
1007 
1008 JNIMETHOD(jlong, newSepia, Java_Beatmup_Imaging_Filters_Sepia, newSepia)(JNIEnv * jenv, jclass) {
1009  BEATMUP_ENTER;
1010  return (jlong) new Beatmup::Filters::Sepia();
1011 }
1012 
1013 /////////////////////////////////////////////////////////////////////////////////////////////
1014 // RESAMPLER
1015 /////////////////////////////////////////////////////////////////////////////////////////////
1016 
1017 JNIMETHOD(jlong, newResampler, Java_Beatmup_Imaging_Resampler, newResampler)(JNIEnv * jenv, jclass, jobject jCtx) {
1018  BEATMUP_ENTER;
1021 }
1022 
1023 
1024 JNIMETHOD(void, setInput, Java_Beatmup_Imaging_Resampler, setInput)
1025  (JNIEnv * jenv, jobject, jlong hInstance, jobject jInput)
1026 {
1027  BEATMUP_ENTER;
1030  resampler->setInput(input);
1031 }
1032 
1033 
1034 JNIMETHOD(void, setOutput, Java_Beatmup_Imaging_Resampler, setOutput)
1036 {
1037  BEATMUP_ENTER;
1040  resampler->setOutput(output);
1041 }
1042 
1043 
1044 JNIMETHOD(void, setMode, Java_Beatmup_Imaging_Resampler, setMode)
1045  (JNIEnv * jenv, jobject, jlong hInstance, jint mode)
1046 {
1047  BEATMUP_ENTER;
1049  resampler->setMode((Beatmup::BitmapResampler::Mode)mode);
1050 }
1051 
1052 
1053 JNIMETHOD(jint, getMode, Java_Beatmup_Imaging_Resampler, getMode)
1054  (JNIEnv * jenv, jobject, jlong hInstance)
1055 {
1056  BEATMUP_ENTER;
1058  return (jint)resampler->getMode();
1059 }
1060 
1061 
1062 JNIMETHOD(void, setCubicParameter, Java_Beatmup_Imaging_Resampler, setCubicParameter)
1063  (JNIEnv * jenv, jobject, jlong hInstance, jfloat val)
1064 {
1065  BEATMUP_ENTER;
1067  resampler->setCubicParameter((float)val);
1068 }
1069 
1070 
1071 JNIMETHOD(jfloat, getCubicParameter, Java_Beatmup_Imaging_Resampler, getCubicParameter)
1072  (JNIEnv * jenv, jobject, jlong hInstance)
1073 {
1074  BEATMUP_ENTER;
1076  return (jfloat)resampler->getCubicParameter();
1077 }
1078 
1079 /////////////////////////////////////////////////////////////////////////////////////////////
1080 // COLOR MATRIX
1081 /////////////////////////////////////////////////////////////////////////////////////////////
1082 
1083 JNIMETHOD(jlong, newColorMatrix__, Java_Beatmup_Imaging_ColorMatrix, newColorMatrix__)(JNIEnv *jenv, jclass) {
1084  BEATMUP_ENTER;
1085  return (jlong) new Beatmup::Color::Matrix();
1086 }
1087 
1088 
1089 JNIMETHOD(jlong, newColorMatrix__FFF, Java_Beatmup_Imaging_ColorMatrix, newColorMatrix__FFF)(JNIEnv *jenv, jclass, jfloat h, jfloat s, jfloat v) {
1090  BEATMUP_ENTER;
1091  return (jlong) new Beatmup::Color::Matrix(h, s, v);
1092 }
1093 
1094 
1095 JNIMETHOD(jlong, newColorMatrix__FFFFF, Java_Beatmup_Imaging_ColorMatrix, newColorMatrix__FFFFF)(JNIEnv *jenv, jclass, jfloat r, jfloat g, jfloat b, jfloat s, jfloat v) {
1096  BEATMUP_ENTER;
1097  return (jlong) new Beatmup::Color::Matrix(
1098  Beatmup::color3f{ r, g, b },
1099  s, v
1100  );
1101 }
1102 
1103 
1104 JNIMETHOD(void, assign, Java_Beatmup_Imaging_ColorMatrix, assign)(JNIEnv *jenv, jclass, jlong hInstTo, jlong hInstFrom) {
1105  BEATMUP_ENTER;
1108  *matTo = *matFrom;
1109 }
1110 
1111 
1112 JNIMETHOD(void, multiply, Java_Beatmup_Imaging_ColorMatrix, multiply)(JNIEnv *jenv, jclass, jlong hLeft, jlong hRight, jlong hResult) {
1113  BEATMUP_ENTER;
1117  *matResult = (*matLeft) * (*matRight);
1118 }
1119 
1120 
1121 JNIMETHOD(jfloat, getElement, Java_Beatmup_Imaging_ColorMatrix, getElement)(JNIEnv *jenv, jobject, jlong hInst, jint x, jint y) {
1122  BEATMUP_ENTER;
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);
1126 #endif
1127  return (jfloat) mat->elem[x][y];
1128 }
1129 
1130 
1131 JNIMETHOD(void, setElement, Java_Beatmup_Imaging_ColorMatrix, setElement)(JNIEnv *jenv, jobject, jlong hInst, jint x, jint y, jfloat v) {
1132  BEATMUP_ENTER;
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);
1136 #endif
1137  mat->elem[x][y] = v;
1138 }
1139 
1140 
1141 /////////////////////////////////////////////////////////////////////////////////////////////
1142 // SHADER
1143 /////////////////////////////////////////////////////////////////////////////////////////////
1144 
1145 JNIMETHOD(jlong, newShader, Java_Beatmup_Shading_ImageShader, newImageShader)(JNIEnv * jenv, jclass, jobject jCtx) {
1146  BEATMUP_ENTER;
1148  return (jlong) new Beatmup::ImageShader(*ctx);
1149 }
1150 
1151 
1152 JNIMETHOD(void, setSourceCode, Java_Beatmup_Shading_ImageShader, setSourceCode)(JNIEnv * jenv, jobject, jlong hInstance, jstring src) {
1153  BEATMUP_ENTER;
1155  const char* javaChar = jenv->GetStringUTFChars(src, 0);
1156  shader->setSourceCode(javaChar);
1157  jenv->ReleaseStringUTFChars(src, javaChar);
1158 }
1159 
1160 
1161 JNIMETHOD(jstring, getInputImageId, Java_Beatmup_Shading_ImageShader, getInputImageId)
1162  (JNIEnv * jenv, jclass)
1163 {
1164  BEATMUP_ENTER;
1165  return jenv->NewStringUTF(Beatmup::ImageShader::INPUT_IMAGE_ID.c_str());
1166 }
1167 
1168 
1169 JNIMETHOD(jstring, getInputImageDeclType, Java_Beatmup_Shading_ImageShader, getInputImageDeclType)
1170  (JNIEnv * jenv, jclass)
1171 {
1172  BEATMUP_ENTER;
1173  return jenv->NewStringUTF(Beatmup::ImageShader::INPUT_IMAGE_DECL_TYPE.c_str());
1174 }
1175 
1176 /////////////////////////////////////////////////////////////////////////////////////////////
1177 // SHADER APPLICATOR
1178 /////////////////////////////////////////////////////////////////////////////////////////////
1179 
1180 JNIMETHOD(jlong, newShaderApplicator, Java_Beatmup_Shading_ShaderApplicator, newShaderApplicator)(JNIEnv * jenv, jclass) {
1181  BEATMUP_ENTER;
1183 }
1184 
1185 
1186 JNIMETHOD(void, addSampler, Java_Beatmup_Shading_ShaderApplicator, addSampler)
1187  (JNIEnv * jenv, jobject, jlong hInst, jobject jBitmap, jstring uniformName)
1188 {
1189  BEATMUP_ENTER;
1192  BEATMUP_STRING(uniformName);
1193  applicator->addSampler(bitmap, uniformNameStr);
1194 }
1195 
1196 
1197 JNIMETHOD(void, setOutput, Java_Beatmup_Shading_ShaderApplicator, setOutput)(JNIEnv * jenv, jobject, jlong hInst, jobject jBitmap) {
1198  BEATMUP_ENTER;
1201  applicator->setOutputBitmap(bitmap);
1202 }
1203 
1204 
1205 JNIMETHOD(void, setShader, Java_Beatmup_Shading_ShaderApplicator, setShader)(JNIEnv * jenv, jobject, jlong hInst, jobject jShader) {
1206  BEATMUP_ENTER;
1209  applicator->setShader(shader);
1210 }
void addJavaReference(JNIEnv *jenv, jobject jobj, const Beatmup::Object *bobj)
Creates new global reference on a Java object to avoid garbage collecting.
Definition: objectpool.h:105
jobject getJavaReference(const Beatmup::Object *bobj) const
Returns a reference to the Java object which a given object depends on.
Definition: objectpool.h:142
JavaFactory factory
Definition: objectpool.h:63
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
Definition: geometry.h:639
void setCenterPosition(const Point &newPos)
Adjusts the mapping origin so that the center of the axes box matches a given point.
Definition: geometry.cpp:67
void scale(float factor, const Point &fixedPoint=Point::ZERO)
Scales the mapping around a given point in target domain.
Definition: geometry.cpp:75
void rotateDegrees(float angle, const Point &fixedPoint=Point::ZERO)
Rotates the mapping around a given point in target domain.
Definition: geometry.cpp:81
Wrapper of Android.Graphics.Bitmap object.
Definition: bitmap.h:34
Android context.
Definition: context.h:32
Image coming from a SurfaceTexture (Camera or video decoder)
A binary pixelwise operation on images.
Definition: operator.h:30
Operation
Binary operation specification.
Definition: operator.h:35
Resamples an image to a given resolution.
Definition: resampler.h:33
Mode
Resampling mode (algorithm) specification.
Definition: resampler.h:38
RGBA color mapping.
Definition: matrix.h:29
Basic class: task and memory management, any kind of static data.
Definition: context.h:59
A task to clip images on CPU.
Definition: crop.h:29
void setOutput(AbstractBitmap *output)
Definition: crop.cpp:103
void setOutputOrigin(IntPoint)
Sets top-left position of the clip rectangle in output bitmap.
Definition: crop.cpp:113
void setCropRect(IntRectangle)
Sets crop rectangle in input bitmap.
Definition: crop.cpp:108
void setInput(AbstractBitmap *input)
Definition: crop.cpp:98
void setElements(float a11, float a12, float a21, float a22)
Sets matrix element values.
Definition: geometry.h:582
float getOrientationDegrees()
Returns first axis orientation in degrees.
Definition: geometry.h:565
Color matrix filter: applies mapping Ax + B at each pixel of a given image in RGBA space.
Definition: color_matrix.h:30
Base class for image filters processing a given bitmap in a pixelwise fashion.
Sepia filter.
Definition: sepia.h:29
Flood fill algorithm implementation.
Definition: flood_fill.h:36
BorderMorphology
Morphological postprocessing operation applied to discovered connected components.
Definition: flood_fill.h:41
A GLSL program to process images.
Definition: image_shader.h:34
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 ...
Definition: image_shader.h:104
static const std::string INPUT_IMAGE_ID
Shader variable name referring to the input image.
Definition: image_shader.h:109
A sequence of integer-valued 2D points.
Definition: contours.h:33
int getPointCount() const
Definition: contours.h:59
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.
Definition: renderer.h:29
bool getOutputPixelsFetching() const
Reports whether the output bitmap pixels are automatically offloaded from GPU to CPU memory every tim...
Definition: renderer.cpp:116
void setScene(Scene *scene)
Definition: renderer.cpp:71
OutputMapping
Scene coordinates to output (screen or bitmap) pixel coordinates mapping.
Definition: renderer.h:34
void resetOutput()
Removes a bitmap from the renderer output, if any, and switches to on-screen rendering.
Definition: renderer.cpp:81
void setOutputPixelsFetching(bool fetch)
Specifies whether the output image data is pulled from GPU to CPU memory every time the rendering is ...
Definition: renderer.cpp:111
void setOutputMapping(const OutputMapping mapping)
Specifies the output mapping specifying how the scene coordinates [0,1]² are mapped to the output (sc...
Definition: renderer.cpp:86
void setOutput(AbstractBitmap *bitmap)
Attaches a bitmap to the renderer output.
Definition: renderer.cpp:76
void setBackgroundImage(AbstractBitmap *)
Sets an image to pave the background.
Definition: renderer.cpp:106
Scene::Layer * pickLayer(float x, float y, bool inPixels) const
Retrieves a scene layer visible at a given point, if any.
Definition: renderer.cpp:121
OutputMapping getOutputMapping() const
Retrieves the output mapping specifying how the scene coordinates [0,1]² are mapped to the output (sc...
Definition: renderer.cpp:91
int getOutputReferenceWidth() const
Definition: renderer.cpp:101
void setOutputReferenceWidth(int newWidth)
Sets a value overriding output width for elements that have their size in pixels, in order to render ...
Definition: renderer.cpp:96
Layer having an image to render.
Definition: scene.h:158
Layer containing a bitmap and a mask applied to the bitmap when rendering.
Definition: scene.h:197
Abstract scene layer having name, type, geometry and some content to display.
Definition: scene.h:64
void setVisible(bool visible)
Sets layer visibility.
Definition: scene.h:124
void setName(const char *name)
Definition: scene.h:95
bool isVisible() const
Returns layer visibility flag.
Definition: scene.h:114
const std::string & getName() const
Definition: scene.h:94
bool isPhantom() const
Returns true if the layer is ignored when searching a layer by point.
Definition: scene.h:119
AffineMapping & getMapping()
Definition: scene.h:97
void setPhantom(bool phantom)
Makes/unmakes the layer "phantom".
Definition: scene.h:130
Bitmap layer using another bitmap as a mask.
Definition: scene.h:217
Bitmap layer using a custom shader.
Definition: scene.h:268
Layer containing a bitmap and a parametric mask (shape)
Definition: scene.h:235
An ordered set of layers representing a renderable content.
Definition: scene.h:37
A task applying an image shader to a bitmap.
static void pullPixels(AbstractBitmap &bitmap)
Copies bitmap from GPU memory to RAM.
Definition: swapper.cpp:48
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)
void invert(AbstractBitmap &input, AbstractBitmap &output)
Inverses colors of an image in a pixelwise fashion.
Definition: tools.cpp:155
4-channel floating point arithmetic
#define BEATMUP_DELETE_REFERENCE(obj)
Definition: wrapper.h:57
BeatmupJavaObjectPool $pool
return JNI_FALSE
Beatmup::Context * ctx
jlong jlong hRight
if(!layer) return NULL
jlong hLeft
JNIEnv jlong jint out
return layer isPhantom() ? JNI_TRUE jlong jfloat jfloat jfloat a11
renderer resetOutput()
Beatmup::InternalBitmap * bitmap
renderer setScene(scene)
jlong jint jint jint jint op1y
jlong hScene
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)
jlong jstring name
jlong jintArray xy
jobject jEnv
* mat
jobject
jobject jCtx
jobject jScene
return layer getInPixels() ? JNI_TRUE jlong jobject jShader
jint * javaxy
return(jlong) new Beatmup jlong hInstance
jlong jfloat jfloat g
return() jlong(new Beatmup::Scene())
BEATMUP_REFERENCE(jLayer, newbie)
Beatmup::IntPoint outOrigin(left, top)
Beatmup::Scene::Layer * layer
JNIEnv * jenv
JNIEnv jlong jint mode
jlong jint jint h
Beatmup::Scene::Layer * newbie
floodFill setBorderPostprocessing((Beatmup::FloodFill::BorderMorphology) op, hold, release)
jlong jint index
crop setInput(input)
jlong jobject size
BEATMUP_CATCH({ return floodFill->getContour(n).getPointCount();})
jlong jlong jint jint jint x2
jlong jobject jMask
return renderer getOutputMapping()
operation setOperand2(bitmap)
renderer setOutputPixelsFetching(fetch==JNI_TRUE)
return bitmap getWidth()
bitmap zero()
jlong jboolean inPixels
jobject jobj
jlong jfloat radius
Beatmup::color3f preservedColor
bitmap bind(jenv, jobj)
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
jlong jboolean flag
return scene getLayerCount()
return(jlong) new Beatmup jlong jlong hInstFrom
jlong jobject jobject jobject op2Origin
jlong jlong jlong hResult
jlong jboolean allow
floodFill setSeeds(xyPtr, count)
jlong jfloat jfloat jfloat b
JNIEnv jlong jobject jOutput
jlong jboolean fetch
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
jlong jfloat jfloat y
return layer isPhantom() ? JNI_TRUE jlong jfloat jfloat jfloat jfloat jfloat a21
jlong jlong hOutputBitmap
filter setHSVCorrection((float) h,(float) s,(float) v)
int pn
JNIEnv jlong jfloat jfloat s
return(jlong) new Beatmup jlong jstring src
jlong jobject jobject jobject jobject outputOrigin
jlong jobject jLayer
jlong jint jfloat jfloat release
jint * xyPtr
jlong jfloat r
filter setColorInversion(preservedColor,(float) s,(float) v)
layer setShader(shader)
* matTo
jlong jobject jobject jSubscene
jlong hRenderer
BEATMUP_ENTER
return $pool getJavaReference & scene(index)
return bitmap getHeight()
JNIEnv jlong jint jfloat bias
bitmap notifyUpdate(width, height)
jlong jboolean visible
jlong hInputBitmap
jlong jint jfloat step
jlong jint op
jlong jint jfloat hold
Beatmup::AffineMapping & mapping
jclass
jlong jobject jInputBitmap
jlong jfloat tolerance
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
operation resetCrop()
jlong hLayer
return layer isPhantom() ? JNI_TRUE jlong jfloat jfloat jfloat jfloat a12
const char * javaChar
BEATMUP_OBJ_OR_NULL(Beatmup::ImageShader, shader, jShader)
jlong jint w
jlong jint jint jint jint jint jint op2y
Beatmup::IntRectangle rect(x1, y1, x2, y2)
jlong jfloat a
resampler setCubicParameter((float) val)
jlong jobject jobject op1Origin
jlong jint jint jint jint jint jint jint jint outy
jlong jlong jint jint y1
renderer setOutput(bitmap)
int count
int n
jlong jint jint jint jint jint op2x
Beatmup::Crop crop
jlong jfloat width
operation setOperand1(bitmap)
jlong jobject jColor
floodFill setMaskPos(p)
jlong jobject jOutputBitmap
jintArray result
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
jobject jint jint height
JNIEnv jlong jfloat val
return renderer getOutputReferenceWidth()
jlong jobject jBitmap
jlong jlong jint x1
shader setSourceCode(javaChar)
jlong jlong jint jint jint jint jint jint top
* matResult
layer getMapping().setCenterPosition(Beatmup jlong jfloat jfloat jfloat fixy
jlong jfloat x
operation setOperation((Beatmup::BitmapBinaryOperation::Operation) op)
BEATMUP_STRING(name)
return bitmap getPixelFormat()
JNIEnv jlong jfloat jfloat jfloat v