App

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

LUTBrush.java
Go to the documentation of this file.
1 package mhr.appcore.tools.brushlike;
2
3 import mhr.appcore.bitmap.NBitmap;
4 import mhr.appcore.blending.BlendMode;
5 import mhr.appcore.blending.Blender;
6 import mhr.appcore.image.Image;
7 import mhr.appcore.image.ImageSelectedState;
8 import mhr.appcore.pointops.LUT;
9 import mhr.appcore.tools.actiondata.ToolActionData;
10 import mhr.appcore.tools.exceptions.ToolNotApplicableException;
11 import mhr.appcore.utils.Rect;
12
16 public abstract class LUTBrush extends BrushLikeTool {
17
18 protected LUT lut = null;
19
29 public LUTBrush(NBitmap brush, double opacity, double flow, double spacing) {
30 super(brush, BrushMode.MODE_ADD, opacity, flow, spacing);
31 }
32
33 @Override
34 public void applyTo(Image img, ToolActionData data) throws ToolNotApplicableException {
35 if (img.getSelectedState() == ImageSelectedState.SELECTED_LAYER) {
36 super.applyTo(img, data);
37 } else {
38 throw new ToolNotApplicableException("Brush tool is not applicable to selected element");
39 }
40 }
41
42 @Override
43 public void onRender(Image i, NBitmap c, NBitmap l, NBitmap o, NBitmap m, Rect src, int srcOrigX, int srcOrigY) {
44 o.copyTo(l, src, srcOrigX, srcOrigY);
45 // Blender.drawTo(blendMode, l, c, color, src, srcOrigX, srcOrigY, opacity);
46 lut.applyTo(l, c, src, srcOrigX, srcOrigY, opacity);
47
48 }
49
50 @Override
51 public void onCommit(Image i, NBitmap c, NBitmap l, NBitmap o, NBitmap m, Rect src, int srcOrigX, int srcOrigY) {
52 // Blender.drawTo(blendMode, o, c, color, src, srcOrigX, srcOrigY, opacity);
53 lut.applyTo(o, c, src, srcOrigX, srcOrigY, opacity);
54 }
55
56 @Override
57 public synchronized void dispose() {
58 if (lut != null) {
59 lut.dispose();
60 lut = null;
61 }
62 super.dispose();
63 }
64 }