home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fs.zip / octave / pnm / SImage / makesimage.m next >
Text File  |  2000-01-15  |  2KB  |  70 lines

  1. # written by Stefan Mueller stm@fgan.de 1996 
  2. function makesimage (X,
  3.                      filename,imagePosX,imagePosY,
  4.                      imageWidth,imageHeight,
  5.                      xStartValue,xEndValue,
  6.                      yStartValue,yEndValue,
  7.                      legendStartValue,legendEndValue,
  8.                      title,labelLegend,legendType,
  9.                      labelWest,labelSouth,labelNorth,labelEast)
  10.   map = colormap;
  11.   frameNorth=60;
  12.   frameSouth=40;
  13.   frameWest=55;
  14.   frameEast=135;
  15.   if (strcmp(legendType,"linear"))
  16.     legendType="le";
  17.   else
  18.     legendType="ll";
  19.   endif
  20.   oct_file = sprintf ("%s.img",filename);
  21.   error_file = "error.tmp";
  22.  
  23. # Save image in octave image file format
  24.   eval (['save -ascii ', oct_file, ' map X']);
  25.   ppmtops = sprintf("pnmtops 2> %s",error_file);
  26.  
  27. # Save octave image file format in eps format 
  28.   img_eps_file = sprintf ("%s.img.eps",filename);
  29.   octtopnm = sprintf ("imgtopnm %s", oct_file);
  30.   mkepsfile = sprintf ("scaleimg -ix %d -iy %d -iw %d -ih %d -x0 %s -xn %s -y0 %s -yn %s -lw %s -ls %s -ln %s -le %s -lt %s -fn %d -fs %d -fw %d -fe %d > %s",
  31.   imagePosX,imagePosY,imageWidth,imageHeight,xStartValue,xEndValue,
  32.   yStartValue,yEndValue,labelWest,labelSouth,labelNorth,labelEast,title,
  33.   frameNorth,frameSouth,frameWest,frameEast,img_eps_file);
  34.   octtops = [ octtopnm, " | ", ppmtops , " | " , mkepsfile];
  35. # octtops = [ octtopnm, " | ", ppmtops , " >mist.ps" ];
  36.   shell_cmd (octtops);
  37.  
  38. # Save colormap in eps format 
  39.   frameNorth=10;
  40.   frameSouth=10;
  41.   frameWest=10;
  42.   frameEast=60;
  43.   imagePosX=imagePosX+imageWidth+60;
  44.   imageWidth=20;
  45.   map_eps_file = sprintf ("%s.map.eps",filename);
  46.   cmaptopnm = sprintf ("imgtopnm -c %s", oct_file);
  47.   mkepsfile = sprintf ("scaleimg -ix %d -iy %d -iw %d -ih %d -y0 %s -yn %s -fn %d -fs %d -fw %d -fe %d -%s %s > %s",
  48.   imagePosX,imagePosY,imageWidth,imageHeight,
  49.   legendStartValue,legendEndValue,
  50.   frameNorth,frameSouth,frameWest,frameEast,
  51.   legendType,labelLegend,map_eps_file);
  52.   cmaptops = [ cmaptopnm, " | ", ppmtops , " | " , mkepsfile];
  53.   shell_cmd (cmaptops);
  54.  
  55.  
  56. # make  two to one eps file
  57.   eps_file = sprintf ("%s.eps",filename);
  58.   merge = sprintf ("cat %s %s >%s",img_eps_file,
  59.     map_eps_file,eps_file);
  60.   shell_cmd (merge);
  61.   merge = sprintf ("echo showpage >>%s",eps_file);
  62.   shell_cmd (merge);
  63.  
  64. # make clean
  65.   rm = sprintf ("rm -f %s %s %s %s",oct_file,error_file,
  66.        map_eps_file,img_eps_file);
  67.   shell_cmd (rm);
  68.  
  69. endfunction
  70.