From: <sm...@us...> - 2009-08-19 19:18:24
|
Revision: 10300 http://plplot.svn.sourceforge.net/plplot/?rev=10300&view=rev Author: smekal Date: 2009-08-19 19:18:06 +0000 (Wed, 19 Aug 2009) Log Message: ----------- D example 20 now produces same results as the C example (wrong color range). Some minor syntax changes as well. Improved loading of pgm file. Modified Paths: -------------- trunk/examples/d/x20d.d Modified: trunk/examples/d/x20d.d =================================================================== --- trunk/examples/d/x20d.d 2009-08-19 17:54:27 UTC (rev 10299) +++ trunk/examples/d/x20d.d 2009-08-19 19:18:06 UTC (rev 10300) @@ -77,7 +77,7 @@ pllab("...around a blue square."," ","A red border should appear..."); - plimage(z, 1.0, XDIM, 1.0, YDIM, 0., 0., 1.0, XDIM, 1., YDIM); + plimage(z, 1.0, XDIM, 1.0, YDIM, 0., 0., 1.0, XDIM, 1.0, YDIM); } PLFLT[] x = new PLFLT[XDIM]; @@ -130,15 +130,15 @@ gray_cmap(num_col); /* display Lena */ - plenv(1., width, 1., height, 1, -1); + plenv(1.0, width, 1.0, height, 1, -1); if(!nointeractive) pllab("Set and drag Button 1 to (re)set selection, Button 2 to finish."," ","Lena..."); else pllab(""," ","Lena..."); - plimage(img_f, 1., width, 1., height, 0., 0., - 1., width, 1., height); + plimage(img_f, 1.0, width, 1.0, height, 0.0, 0.0, + 1.0, width, 1.0, height); /* selection/expansion demo */ if(!nointeractive) { @@ -156,13 +156,13 @@ pladv(0); /* display selection only */ - plimage(img_f, 1., width, 1., height, 0., 0., xi, xe, ye, yi); + plimage(img_f, 1.0, width, 1.0, height, 0.0, 0.0, xi, xe, ye, yi); plspause(1); /* zoom in selection */ plenv(xi, xe, ye, yi, 1, -1); - plimage(img_f, 1., width, 1., height, 0., 0., xi, xe, ye, yi); + plimage(img_f, 1.0, width, 1.0, height, 0.0, 0.0, xi, xe, ye, yi); } /* Base the dynamic range on the image contents. */ @@ -174,7 +174,7 @@ plcol0(2); plenv(0, width, 0, height, 1, -1); pllab("", "", "Reduced dynamic range image example"); - plimagefr(img_f, 0.0, cast(PLFLT)width, 0.0, cast(PLFLT)height, 0.0, 0.0, + plimagefr(img_f, 0.0, width, 0.0, height, 0.0, 0.0, img_min+img_max*0.25, img_max-img_max*0.25); /* Draw a distorted version of the original image, showing its full dynamic range. */ @@ -198,7 +198,7 @@ /* read image from file in binary ppm format */ int read_img(string fname, out PLFLT[][] img_f, out int width, out int height, out int num_col) { - char* img; + ubyte[] img; BufferedFile input = new BufferedFile; try { @@ -224,14 +224,15 @@ if(input.readf("%d %d %d", &width, &height, &num_col) != 9) /* width, height num colors */ return 1; - img = (new char[width*height]).ptr; + img = new ubyte[width*height]; img_f = new PLFLT[][width]; for(int i=0; i<width; i++) img_f[i] = new PLFLT[height]; - input.readExact(img, width*height); - } catch(OpenException exception) { + if(input.read(img) != width*height) + return 1; + } catch(Exception except) { return 1; } finally { input.close(); @@ -279,6 +280,6 @@ PLFLT[] b = [ 0.0, 1.0 ]; PLFLT[] pos = [ 0.0, 1.0 ]; - plscmap1n(256); + plscmap1n(num_col); plscmap1l(1, pos, r, g, b); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2011-09-14 14:23:29
|
Revision: 11924 http://plplot.svn.sourceforge.net/plplot/?rev=11924&view=rev Author: andrewross Date: 2011-09-14 14:23:22 +0000 (Wed, 14 Sep 2011) Log Message: ----------- Need to zero z array if the dbg option is set. Modified Paths: -------------- trunk/examples/d/x20d.d Modified: trunk/examples/d/x20d.d =================================================================== --- trunk/examples/d/x20d.d 2011-09-14 08:48:17 UTC (rev 11923) +++ trunk/examples/d/x20d.d 2011-09-14 14:23:22 UTC (rev 11924) @@ -66,6 +66,11 @@ { plenv( 1.0, XDIM, 1.0, YDIM, 1, 1 ); // no plot box + // Zero z array before use + for ( int j = 0; j < YDIM; j++ ) + for ( int i = 0; i < XDIM; i++ ) + z[i][j] = 0.0; + // build a one pixel square border, for diagnostics for ( int i = 0; i < XDIM; i++ ) z[i][YDIM - 1] = 1.0; // right This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2013-10-02 09:23:13
|
Revision: 12568 http://sourceforge.net/p/plplot/code/12568 Author: andrewross Date: 2013-10-02 09:23:08 +0000 (Wed, 02 Oct 2013) Log Message: ----------- Fix bug in D example 20. Won't compile with latest version of gdc. Modified Paths: -------------- trunk/examples/d/x20d.d Modified: trunk/examples/d/x20d.d =================================================================== --- trunk/examples/d/x20d.d 2013-10-01 21:20:49 UTC (rev 12567) +++ trunk/examples/d/x20d.d 2013-10-02 09:23:08 UTC (rev 12568) @@ -6,6 +6,7 @@ import std.math; import std.stdio; +import std.file; import plplot; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |