File tree Expand file tree Collapse file tree 6 files changed +118
-2
lines changed Expand file tree Collapse file tree 6 files changed +118
-2
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ started 8.5 24/1/17
3
3
- gaussnoise goes via vips8 now
4
4
- add snake option to array join [Joe Padfield]
5
5
- parse_float was broken for numbers starting "0."
6
+ - add alpha section to Image / Band menu ... Flatten, Premultiply,
7
+ Unpremultiply, Blend
6
8
7
9
started 8.4.1 25/9/16
8
10
- simplify nip2-icon.rc build, bgilbert
Original file line number Diff line number Diff line change @@ -1005,7 +1005,7 @@ Filter_blend_item = class
1005
1005
}
1006
1006
1007
1007
Blend_alpha_item = class
1008
- Menuaction "_Alpha" "blend images with optional alpha channels" {
1008
+ Menuaction "Blend _Alpha" "blend images with optional alpha channels" {
1009
1009
// usage: layerit foreground background
1010
1010
// input images must be either 1 or 3 bands, optionally + 1 band
1011
1011
// which is used as the alpha channel
Original file line number Diff line number Diff line change @@ -1062,6 +1062,30 @@ Image_band_item = class
1062
1062
1063
1063
sep1 = Menuseparator;
1064
1064
1065
+ Flatten_item = class Menuaction "_Flatten" "flatten alpha out of image" {
1066
+ action x = class
1067
+ _result {
1068
+ _vislevel = 3;
1069
+
1070
+ bg = Expression "Background" 0;
1071
+
1072
+ _result = map_unary (flattenimage bg) x;
1073
+ }
1074
+ }
1075
+
1076
+ Premultiply_item = class Menuaction "_Premultiply" "premultiply alpha" {
1077
+ action x = premultiply x;
1078
+ }
1079
+
1080
+ Unpremultiply_item = class
1081
+ Menuaction "_Unpremultiply" "unpremultiply alpha" {
1082
+ action x = unpremultiply x;
1083
+ }
1084
+
1085
+ Blend_alpha_item = Filter_blend_item.Blend_alpha_item;
1086
+
1087
+ sep1a = Menuseparator;
1088
+
1065
1089
Bandand_item = class
1066
1090
Menuaction "Bitwise Band AND" "bitwise AND of image bands" {
1067
1091
action x = bandand x;
Original file line number Diff line number Diff line change @@ -21,6 +21,36 @@ to_matrix x
21
21
= error (_ "not image");
22
22
}
23
23
24
+ /* Try to make a Vector ... works for Vector/Image/Real, plus image/real
25
+ */
26
+ to_vector x
27
+ = to_vector x.expr, is_Expression x
28
+ = x, is_Vector x
29
+ = oo_unary_function to_vector_op x, is_class x
30
+ = tov x
31
+ {
32
+ to_vector_op = Operator "to_vector" tov Operator_type.COMPOUND false;
33
+
34
+ tov x
35
+ = Vector (itov x), is_image x
36
+ = Vector [x], is_real x
37
+ = Vector x, is_real_list x
38
+ = Vector x?0, is_matrix x && len x == 1
39
+ = Vector (transpose x)?0, is_matrix x && len x?0 == 1
40
+ = error (_ "bad arguments to " ++ "to_vector");
41
+
42
+ itov i
43
+ = v, is_image i
44
+ = error (_ "not image")
45
+ {
46
+ m = im_vips2mask ((double) i);
47
+ v
48
+ = m.value?0, m.height == 1
49
+ = (transpose m.value)?0, m.width == 1
50
+ = error (_ "image is not 1xN or Nx1");
51
+ }
52
+ }
53
+
24
54
/* Try to make an Image ... works for Vector/Matrix/Real, plus image/real
25
55
* Special case for Colour ... pull out the colour_space and set Type in the
26
56
* image.
Original file line number Diff line number Diff line change @@ -2528,3 +2528,53 @@ gaussnoise width height mean sigma
2528
2528
$sigma => to_real sigma
2529
2529
];
2530
2530
}
2531
+
2532
+ flattenimage bg x
2533
+ = oo_unary_function flatten_op x, is_class x
2534
+ = flt (to_vector bg) x, is_image x
2535
+ = error (_ "bad arguments to " ++ "flattenimage")
2536
+ {
2537
+ flatten_op = Operator "flatten"
2538
+ (flattenimage bg) Operator_type.COMPOUND_REWRAP false;
2539
+
2540
+ flt bg x
2541
+ = out
2542
+ {
2543
+ [out] = vips_call "flatten" [x] [
2544
+ $background => bg.value
2545
+ ];
2546
+ }
2547
+ }
2548
+
2549
+ premultiply x
2550
+ = oo_unary_function premultiply_op x, is_class x
2551
+ = prem x, is_image x
2552
+ = error (_ "bad arguments to " ++ "premultiply")
2553
+ {
2554
+ premultiply_op = Operator "premultiply"
2555
+ premultiply Operator_type.COMPOUND_REWRAP false;
2556
+
2557
+ prem x
2558
+ = out
2559
+ {
2560
+ [out] = vips_call "premultiply" [x] [
2561
+ ];
2562
+ }
2563
+ }
2564
+
2565
+ unpremultiply x
2566
+ = oo_unary_function unpremultiply_op x, is_class x
2567
+ = unprem x, is_image x
2568
+ = error (_ "bad arguments to " ++ "unpremultiply")
2569
+ {
2570
+ unpremultiply_op = Operator "unpremultiply"
2571
+ unpremultiply Operator_type.COMPOUND_REWRAP false;
2572
+
2573
+ unprem x
2574
+ = out
2575
+ {
2576
+ [out] = vips_call "unpremultiply" [x] [
2577
+ ];
2578
+ }
2579
+ }
2580
+
Original file line number Diff line number Diff line change @@ -1891,7 +1891,7 @@ heap_ip_to_gvalue( PElement *in, GValue *out )
1891
1891
im_ref_string_set ( out , name );
1892
1892
}
1893
1893
#if VIPS_MAJOR_VERSION > 7 || VIPS_MINOR_VERSION > 39
1894
- /* vips_value_set_array_image () is a 7.40 feature.
1894
+ /* vips_value_set_array_* () is a 7.40 feature.
1895
1895
*/
1896
1896
else if ( heap_is_imagevec ( in , & result ) &&
1897
1897
result ) {
@@ -1914,6 +1914,16 @@ heap_ip_to_gvalue( PElement *in, GValue *out )
1914
1914
g_object_ref ( ivec [i ] );
1915
1915
}
1916
1916
}
1917
+ else if ( heap_is_realvec ( in , & result ) &&
1918
+ result ) {
1919
+ double realvec [100 ];
1920
+ int n ;
1921
+
1922
+ if ( (n = heap_get_realvec ( in , realvec , 100 )) < 0 )
1923
+ return ( FALSE );
1924
+ g_value_init ( out , VIPS_TYPE_ARRAY_DOUBLE );
1925
+ vips_value_set_array_double ( out , realvec , n );
1926
+ }
1917
1927
#endif
1918
1928
else {
1919
1929
error_top ( _ ( "Unimplemented list type." ) );
You can’t perform that action at this time.
0 commit comments