Skip to content

Commit

Permalink
add test composite filters
Browse files Browse the repository at this point in the history
  • Loading branch information
jcupitt committed Oct 4, 2017
1 parent 0cf06c9 commit 35aa27b
Show file tree
Hide file tree
Showing 2 changed files with 162 additions and 1 deletion.
161 changes: 161 additions & 0 deletions share/nip2/start/Filter.def
@@ -1,3 +1,164 @@
Blend_type = class {
CLEAR = 0;
SOURCE = 1;
OVER = 2;
IN = 3;
OUT = 4;
ATOP = 5;
DEST = 6;
DEST_OVER = 7;
DEST_IN = 8;
DEST_OUT = 9;
DEST_ATOP = 10;
XOR = 11;
ADD = 12;
SATURATE = 13;
MULTIPLY = 14;
SCREEN = 15;
OVERLAY = 16;
DARKEN = 17;
LIGHTEN = 18;
COLOUR_DODGE = 19;
COLOUR_BURN = 20;
HARD_LIGHT = 21;
SOFT_LIGHT = 22;
DIFFERENCE = 23;
EXCLUSION = 24;

/* Table to map blend numbers to descriptive strings
*/
descriptions = [
_ "Clear",
_ "Source",
_ "Over",
_ "In",
_ "Out",
_ "Atop",
_ "Dest",
_ "Dest over",
_ "Dest in",
_ "Dest out",
_ "Dest atop",
_ "Xor",
_ "Add",
_ "Saturate",
_ "Multiply",
_ "Screen",
_ "Overlay",
_ "Darken",
_ "Lighten",
_ "Colour dodge",
_ "Colour burn",
_ "Hard light",
_ "Soft light",
_ "Difference",
_ "Exclusion"
];

/* And to vips enum nicknames.
*/
types = Enum [
$clear => "clear",
$source => "source",
$over => "over",
$in => "in",
$out => "out",
$atop => "atop",
$dest => "dest",
$dest_over => "dest_over",
$dest_in => "dest_in",
$dest_out => "dest_out",
$dest_atop => "dest_atop",
$xor => "xor",
$add => "add",
$saturate => "saturate",
$multiply => "multiply",
$screen => "screen",
$overlay => "overlay",
$darken => "darken",
$lighten => "lighten",
$colour_dodge => "colour_dodge",
$colour_burn => "colour_burn",
$hard_light => "hard_light",
$soft_light => "soft_light",
$difference => "difference",
$exclusion => "exclusion"
];
}

Blend type = class {
value = Blend_type.types?type;
}

Blend_over = Blend Blend_type.OVER;

Blend_picker default = class
Blend blend.value {
_vislevel = 2;

blend = Option "Blend" Blend_type.descriptions default;
}

Composite2_item = class
Menuaction "_Composite two" "composite a pair of images" {
action x y = class
_result {
_vislevel = 3;

blend = Option_enum (_ "Blend mode") modes "over"
{
modes = Blend_type.types;
}
compositing_space = Option_enum (_ "Compositing space") spaces "sRGB"
{
spaces = Image_type.image_colour_spaces;
}
premultiplied = Toggle (_ "Premultiplied") false;

_result
= Image output
{
[output] = vips_call "composite"
[[y.value, x.value], blend.value]
[$compositing_space => compositing_space.value_thing,
$premultiplied => premultiplied.value
];
}
}
}

Composite3_item = class
Menuaction "_Composite three" "composite three images" {
action x y z = class
_result {
_vislevel = 3;

blend1 = Option_enum (_ "Blend mode") modes "over"
{
modes = Blend_type.types;
}
blend2 = Option_enum (_ "Blend mode") modes "over"
{
modes = Blend_type.types;
}
compositing_space = Option_enum (_ "Compositing space") spaces "sRGB"
{
spaces = Image_type.image_colour_spaces;
}
premultiplied = Toggle (_ "Premultiplied") false;

_result
= Image output
{
[output] = vips_call "composite"
[[z.value, y.value, x.value], [blend1.value, blend2.value]]
[$compositing_space => compositing_space.value_thing,
$premultiplied => premultiplied.value
];
}
}
}

Filter_conv_item = class
Menupullright "_Convolution" "various spatial convolution filters" {
/* Some useful masks.
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Expand Up @@ -320,7 +320,7 @@ nipmarshal.c:
nip2-model.o model.o: model.c parse.c

AM_CPPFLAGS = @IP_CFLAGS@
LDADD = @IP_CFLAGS@ @IP_LIBS@
LDADD = @IP_CFLAGS@ @IP_LIBS@ -lfl
AM_LDFLAGS = @LDFLAGS@

dist-hook:
Expand Down

0 comments on commit 35aa27b

Please sign in to comment.