[sac-user] [sac-devel] filename string not passed through to writePNG(..)

Artem Shinkarov artyom.shinkaroff at gmail.com
Wed Feb 17 22:04:25 CET 2016


On 16-02-17 17:30:06, Scholz, Sven-Bodo wrote:
> In case you are not subscribed to sac-user (which you should(!) :-) here an outcry for help :-)

Yeah, we have been looking at this issue with Hans recently.
Something weird is happening at the expansion of the ICM-macros in
array2png.c.  A very similar code in the SimpleImage module works 
fine, but in array2png it fails to retrieve the shape of the
argument-array correctly...

How do I subscribe to sac-user?  Does the form at
http://lists.sac-home.org/mailman/listinfo/sac-user
works?  Or someone should add me there explicitly.


Artem


> Bodo
> 
> > On 16 Feb 2016, at 23:53, Rob Stewart <R.Stewart at hw.ac.uk> wrote:
> > 
> > I have some code that:
> > 
> > use PNG: {writePNG};
> > 
> > And
> > 
> > call writePNG("foo.png", anArray);
> > 
> > When I compile and run this, I am getting the runtime error:
> > 
> > *** SAC runtime error
> > *** SAC_PNG_array2png: Failed to open image file '': No such file or directory
> > 
> > My "foo.png" doesn't look to be carried through correctly to
> > writePNG(..).
> > 
> > In the stdlib/src/world/stdio/PNG.sac
> > 
> > --8<---------------cut here---------------start------------->8---
> > external void writePNG( string NAME, color[.,.] array);
> >    #pragma effect FileSystem::TheFileSystem
> >    #pragma linkobj "src/PNG/array2png.o"
> >    #pragma linkname "SAC_PNG_array2png"
> >    #pragma linkwith "png"
> >    #pragma linkwith "z"
> >    #pragma refcounting[1]
> > --8<---------------cut here---------------end--------------->8---
> > 
> > And in stdlib/src/world/stdio/src/PNG/array2png.c I get this far:
> > 
> > --8<---------------cut here---------------start------------->8---
> > void SAC_PNG_array2png(SAC_ND_PARAM_out_nodesc(res_nt, int),
> >                       SAC_ND_PARAM_in_nodesc(string_nt, string),
> >                       SAC_ND_PARAM_in(ar_nt, int))
> > {
> >  FILE *fp;
> >  png_structp png_ptr;
> >  png_infop info_ptr;
> >  png_bytep *row_pointers;
> >  png_bytep img_data;
> >  int x, y;
> >  int height = SAC_ND_A_DESC_SHAPE(ar_nt, 0);
> >  int width = SAC_ND_A_DESC_SHAPE(ar_nt, 1);
> >  int *arr_data = SAC_ND_A_FIELD(ar_nt);
> > 
> >  fp = fopen(NT_NAME(string_nt), "wb");
> >  if (fp == NULL)
> >  {
> >    SAC_RuntimeError("SAC_PNG_array2png: Failed to open image file '%s': %s",
> >                     NT_NAME(string_nt), strerror(errno));
> >    return;
> >  }
> > --8<---------------cut here---------------end--------------->8---
> > 
> > 
> > Why does NT_NAME(string_nt) return an empty string, and what can I do
> > about it? Or am I missing something completely obvious?
> > 
> > Thanks,
> > 
> > --
> > Rob
> > _______________________________________________
> > sac-user mailing list
> > sac-user at sac-home.org
> > http://lists.sac-home.org/mailman/listinfo/sac-user



More information about the sac-user mailing list