diff --git a/TODO b/TODO index a173d5b7..4ead5e91 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,3 @@ -- add tests for perlin and worley noise generators - - add more webp tests to py suite - try moving some more of the CLI tests to py diff --git a/cplusplus/gen-operators.py b/cplusplus/gen-operators.py index c64d1bf3..9be011fb 100755 --- a/cplusplus/gen-operators.py +++ b/cplusplus/gen-operators.py @@ -22,6 +22,8 @@ import re import logging #logging.basicConfig(level = logging.DEBUG) +import gi +gi.require_version('Vips', '8.0') from gi.repository import Vips, GObject vips_type_image = GObject.GType.from_name("VipsImage") diff --git a/cplusplus/include/vips/gen-operators-h.py b/cplusplus/include/vips/gen-operators-h.py index 6c76c257..aa0a96d0 100755 --- a/cplusplus/include/vips/gen-operators-h.py +++ b/cplusplus/include/vips/gen-operators-h.py @@ -12,6 +12,8 @@ import re import logging #logging.basicConfig(level = logging.DEBUG) +import gi +gi.require_version('Vips', '8.0') from gi.repository import Vips, GObject vips_type_image = GObject.GType.from_name("VipsImage") diff --git a/cplusplus/include/vips/vips-operators.h b/cplusplus/include/vips/vips-operators.h index 92b30b1f..620465a8 100644 --- a/cplusplus/include/vips/vips-operators.h +++ b/cplusplus/include/vips/vips-operators.h @@ -1,7 +1,3 @@ -// headers for vips operations -// Fri Feb 12 20:04:03 GMT 2016 -// this file is generated automatically, do not edit! - static void system( char * cmd_format , VOption *options = 0 ); VImage add( VImage right , VOption *options = 0 ); VImage subtract( VImage right , VOption *options = 0 ); @@ -103,13 +99,15 @@ VImage invertlut( VOption *options = 0 ); static VImage tonelut( VOption *options = 0 ); static VImage identity( VOption *options = 0 ); static VImage fractsurf( int width , int height , double fractal_dimension , VOption *options = 0 ); -static VImage radload( char * filename , VOption *options = 0 ); -static VImage ppmload( char * filename , VOption *options = 0 ); +static VImage worley( int width , int height , VOption *options = 0 ); +static VImage perlin( int width , int height , VOption *options = 0 ); static VImage csvload( char * filename , VOption *options = 0 ); static VImage matrixload( char * filename , VOption *options = 0 ); -static VImage analyzeload( char * filename , VOption *options = 0 ); static VImage rawload( char * filename , int width , int height , int bands , VOption *options = 0 ); static VImage vipsload( char * filename , VOption *options = 0 ); +static VImage analyzeload( char * filename , VOption *options = 0 ); +static VImage ppmload( char * filename , VOption *options = 0 ); +static VImage radload( char * filename , VOption *options = 0 ); static VImage pdfload( char * filename , VOption *options = 0 ); static VImage pdfload_buffer( VipsBlob * buffer , VOption *options = 0 ); static VImage svgload( char * filename , VOption *options = 0 ); @@ -130,15 +128,15 @@ static VImage magickload( char * filename , VOption *options = 0 ); static VImage magickload_buffer( VipsBlob * buffer , VOption *options = 0 ); static VImage fitsload( char * filename , VOption *options = 0 ); static VImage openexrload( char * filename , VOption *options = 0 ); -void radsave( char * filename , VOption *options = 0 ); -VipsBlob * radsave_buffer( VOption *options = 0 ); -void ppmsave( char * filename , VOption *options = 0 ); void csvsave( char * filename , VOption *options = 0 ); void matrixsave( char * filename , VOption *options = 0 ); void matrixprint( VOption *options = 0 ); void rawsave( char * filename , VOption *options = 0 ); void rawsave_fd( int fd , VOption *options = 0 ); void vipssave( char * filename , VOption *options = 0 ); +void ppmsave( char * filename , VOption *options = 0 ); +void radsave( char * filename , VOption *options = 0 ); +VipsBlob * radsave_buffer( VOption *options = 0 ); void dzsave( char * filename , VOption *options = 0 ); void pngsave( char * filename , VOption *options = 0 ); VipsBlob * pngsave_buffer( VOption *options = 0 ); diff --git a/cplusplus/vips-operators.cpp b/cplusplus/vips-operators.cpp index ddbef979..1cb98e9f 100644 --- a/cplusplus/vips-operators.cpp +++ b/cplusplus/vips-operators.cpp @@ -1,7 +1,3 @@ -// bodies for vips operations -// Fri Feb 12 20:03:53 GMT 2016 -// this file is generated automatically, do not edit! - void VImage::system( char * cmd_format , VOption *options ) { call( "system" , @@ -1321,26 +1317,28 @@ VImage VImage::fractsurf( int width , int height , double fractal_dimension , VO return( out ); } -VImage VImage::radload( char * filename , VOption *options ) +VImage VImage::worley( int width , int height , VOption *options ) { VImage out; - call( "radload" , + call( "worley" , (options ? options : VImage::option()) -> - set( "filename", filename ) -> - set( "out", &out ) ); + set( "out", &out ) -> + set( "width", width ) -> + set( "height", height ) ); return( out ); } -VImage VImage::ppmload( char * filename , VOption *options ) +VImage VImage::perlin( int width , int height , VOption *options ) { VImage out; - call( "ppmload" , + call( "perlin" , (options ? options : VImage::option()) -> - set( "filename", filename ) -> - set( "out", &out ) ); + set( "out", &out ) -> + set( "width", width ) -> + set( "height", height ) ); return( out ); } @@ -1369,18 +1367,6 @@ VImage VImage::matrixload( char * filename , VOption *options ) return( out ); } -VImage VImage::analyzeload( char * filename , VOption *options ) -{ - VImage out; - - call( "analyzeload" , - (options ? options : VImage::option()) -> - set( "filename", filename ) -> - set( "out", &out ) ); - - return( out ); -} - VImage VImage::rawload( char * filename , int width , int height , int bands , VOption *options ) { VImage out; @@ -1408,6 +1394,42 @@ VImage VImage::vipsload( char * filename , VOption *options ) return( out ); } +VImage VImage::analyzeload( char * filename , VOption *options ) +{ + VImage out; + + call( "analyzeload" , + (options ? options : VImage::option()) -> + set( "filename", filename ) -> + set( "out", &out ) ); + + return( out ); +} + +VImage VImage::ppmload( char * filename , VOption *options ) +{ + VImage out; + + call( "ppmload" , + (options ? options : VImage::option()) -> + set( "filename", filename ) -> + set( "out", &out ) ); + + return( out ); +} + +VImage VImage::radload( char * filename , VOption *options ) +{ + VImage out; + + call( "radload" , + (options ? options : VImage::option()) -> + set( "filename", filename ) -> + set( "out", &out ) ); + + return( out ); +} + VImage VImage::pdfload( char * filename , VOption *options ) { VImage out; @@ -1648,34 +1670,6 @@ VImage VImage::openexrload( char * filename , VOption *options ) return( out ); } -void VImage::radsave( char * filename , VOption *options ) -{ - call( "radsave" , - (options ? options : VImage::option()) -> - set( "in", *this ) -> - set( "filename", filename ) ); -} - -VipsBlob * VImage::radsave_buffer( VOption *options ) -{ - VipsBlob * buffer; - - call( "radsave_buffer" , - (options ? options : VImage::option()) -> - set( "in", *this ) -> - set( "buffer", &buffer ) ); - - return( buffer ); -} - -void VImage::ppmsave( char * filename , VOption *options ) -{ - call( "ppmsave" , - (options ? options : VImage::option()) -> - set( "in", *this ) -> - set( "filename", filename ) ); -} - void VImage::csvsave( char * filename , VOption *options ) { call( "csvsave" , @@ -1723,6 +1717,34 @@ void VImage::vipssave( char * filename , VOption *options ) set( "filename", filename ) ); } +void VImage::ppmsave( char * filename , VOption *options ) +{ + call( "ppmsave" , + (options ? options : VImage::option()) -> + set( "in", *this ) -> + set( "filename", filename ) ); +} + +void VImage::radsave( char * filename , VOption *options ) +{ + call( "radsave" , + (options ? options : VImage::option()) -> + set( "in", *this ) -> + set( "filename", filename ) ); +} + +VipsBlob * VImage::radsave_buffer( VOption *options ) +{ + VipsBlob * buffer; + + call( "radsave_buffer" , + (options ? options : VImage::option()) -> + set( "in", *this ) -> + set( "buffer", &buffer ) ); + + return( buffer ); +} + void VImage::dzsave( char * filename , VOption *options ) { call( "dzsave" , diff --git a/libvips/create/perlin.c b/libvips/create/perlin.c index d01e3a79..e006a5a6 100644 --- a/libvips/create/perlin.c +++ b/libvips/create/perlin.c @@ -140,16 +140,17 @@ vips_perlin_create_cells( VipsPerlin *perlin, /* When we calculate the seed for this cell, we wrap * around so that our output will tesselate. */ - if( cx >= perlin->cells_across ) - cx = 0; - seed = vips_perlin_seed_add( seed, cx ); if( cy >= perlin->cells_down ) cy = 0; seed = vips_perlin_seed_add( seed, cy ); + if( cx >= perlin->cells_across ) + cx = 0; + seed = vips_perlin_seed_add( seed, cx ); + seed = vips_perlin_random( seed ); - angle = seed & 0xff; + angle = (seed ^ (seed >> 8) ^ (seed >> 16)) & 0xff; gx[ci] = vips_perlin_cos[angle]; gy[ci] = vips_perlin_sin[angle]; diff --git a/python/find_class_methods.py b/python/find_class_methods.py index 9fc31e3f..93c55159 100755 --- a/python/find_class_methods.py +++ b/python/find_class_methods.py @@ -5,6 +5,8 @@ import sys import logging #logging.basicConfig(level = logging.DEBUG) +import gi +gi.require_version('Vips', '8.0') from gi.repository import Vips, GObject # Search for all VipsOperation which don't have an input image object ... these diff --git a/python/packages/gi/overrides/Vips.py b/python/packages/gi/overrides/Vips.py index 0a78fbda..b015779e 100644 --- a/python/packages/gi/overrides/Vips.py +++ b/python/packages/gi/overrides/Vips.py @@ -1093,6 +1093,8 @@ class_methods = [ "mask_fractal", "tonelut", "identity", + "perlin", + "worley", "fractsurf", "radload", "ppmload", diff --git a/test/test_create.py b/test/test_create.py index d0048625..861ee07d 100755 --- a/test/test_create.py +++ b/test/test_create.py @@ -441,5 +441,19 @@ class TestCreate(unittest.TestCase): self.assertEqual(im.bands, 1) self.assertEqual(im.format, Vips.BandFormat.FLOAT) + def test_worley(self): + im = Vips.Image.worley(512, 512) + self.assertEqual(im.width, 512) + self.assertEqual(im.height, 512) + self.assertEqual(im.bands, 1) + self.assertEqual(im.format, Vips.BandFormat.INT) + + def test_perlin(self): + im = Vips.Image.perlin(512, 512) + self.assertEqual(im.width, 512) + self.assertEqual(im.height, 512) + self.assertEqual(im.bands, 1) + self.assertEqual(im.format, Vips.BandFormat.FLOAT) + if __name__ == '__main__': unittest.main()