home *** CD-ROM | disk | FTP | other *** search
- #include <exec/types.h>
- #include <stdio.h>
- #include <string.h>
- #include <intuition/intuition.h>
- #include <libraries/dos.h>
-
- #include <proto/dos.h>
- #include <proto/intuition.h>
- #include <proto/graphics.h>
-
-
- #include "View_define.h"
- #include "Viewprotos.h"
-
- #define PWWIDTH 600
- #define PWHEIGHT 26
-
- /* NewWindow structure for progress window */
-
- struct NewWindow PNW =
- {
- 20, 40,
- PWWIDTH, PWHEIGHT,
- 2, 1,
- NULL,
- WINDOWDEPTH|WINDOWDRAG|SMART_REFRESH,
- NULL,
- NULL,
- "Printing Progress",
- NULL,
- NULL,
- 0,0,
- 0,0,
- CUSTOMSCREEN
- };
-
- struct Window *progwin=NULL;
-
- extern float min, max;
- extern struct Screen *gScreen;
- extern char hdfdirname[81];
- extern char hdffilename[81];
-
- int
- DumpPS(unsigned char *Image,int width, int height,
- char *filename)
- {
- register int i;
- FILE *fp=NULL;
- char *buffer;
- char buffer2[81];
- BOOL ret;
- int extras;
- unsigned char *imadr;
-
- scrollUp(gScreen,10);
- strcpy(buffer2,hdffilename);
- strcat(buffer2,".ps");
-
- if(!(buffer=getFilename(buffer2,hdfdirname,
- "Save to PS File...","#?.ps")))
- {
- scrollDown(gScreen,180);
- return(0);
- }
- fp = fopen(buffer,"w");
- if(fp==NULL) {
- request("Can't open file for writing!",NULL);
- scrollDown(gScreen,180);
- return(0);
- }
-
- PNW.Screen = gScreen;
- progwin = OpenWindow(&PNW);
- if(progwin==NULL) {
- request("Error: Can't open print window", NULL);
- scrollDown(gScreen,180);
- return(0);
- }
-
-
- scrollDown(gScreen,140);
- SetAPen(progwin->RPort,2);
- RectFill(progwin->RPort,5,12,594,22);
-
- fprintf(fp,"%%!\n\n");
- fprintf(fp,"/inch { 72 mul } def\n");
- fprintf(fp,"/myxoffset { .75 inch } def\n");
- fprintf(fp,"/myyoffset { 2.0 inch } def\n");
- fprintf(fp,"/myxsize { 7 inch } def\n");
- fprintf(fp,"/myysize { 7 inch } def\n");
- fprintf(fp,"/negmyxsize { -7 inch } def\n\n");
- fprintf(fp,"/picstr %d string def\n",width);
- fprintf(fp,"/sclstr 256 string def\n\n");
- fprintf(fp,"/Times-Bold findfont 12 scalefont setfont\n");
- fprintf(fp,"1 inch 1 inch moveto\n");
- fprintf(fp,"(%s) show\n",filename);
- if(max>min)
- {
- fprintf(fp,".75 inch 9.5 inch moveto");
- fprintf(fp,"(Min: %3.2e) show\n",min);
- fprintf(fp,"6.5 inch 9.5 inch moveto");
- fprintf(fp,"(Max: %3.2e) show\n",max);
- }
- fprintf(fp,"newpath\n");
- fprintf(fp,"myxoffset myyoffset moveto\n");
- fprintf(fp,"myxsize 0 rlineto\n");
- fprintf(fp,"0 myysize rlineto\n");
- fprintf(fp,"negmyxsize 0 rlineto\n");
- fprintf(fp,"closepath\n2 setlinewidth\nstroke\n\n");
-
- fprintf(fp,"myxoffset myyoffset translate\n");
- fprintf(fp,"myxsize myysize scale\n\n");
- fprintf(fp,"%d %d 8\n",width,height);
- fprintf(fp,"[%d 0 0 -%d 0 %d]\n",width,height,height);
- fprintf(fp,"{currentfile\n picstr readhexstring pop}\nimage\n");
-
- SetAPen(progwin->RPort,3);
- extras = (width*height)%16;
- for(i=0;i<=width*height-16;i+=16)
- {
- imadr = Image+i;
- fprintf(fp,"%02.2x%02.2x%02.2x%02.2x%02.2x%02.2x%02.2x%02.2x%02.2x%02.2x%02.2x%02.2x%02.2x%02.2x%02.2x%02.2x\n",
- 255- *(imadr),
- 255- *(imadr+1),
- 255- *(imadr+2),
- 255- *(imadr+3),
- 255- *(imadr+4),
- 255- *(imadr+5),
- 255- *(imadr+6),
- 255- *(imadr+7),
- 255- *(imadr+8),
- 255- *(imadr+9),
- 255- *(imadr+10),
- 255- *(imadr+11),
- 255- *(imadr+12),
- 255- *(imadr+13),
- 255- *(imadr+14),
- 255- *(imadr+15)
- );
- RectFill(progwin->RPort,5,
- 12,i*594/(width*height),22);
- }
- for(i=width*height-extras;i<width*height;i++)
- {
- fprintf(fp,"%02.2x",255- (*(Image+i)));
- }
- fprintf(fp,"\n");
-
-
- fprintf(fp,"0 1.1 translate\n");
- fprintf(fp,"1 0.075 scale \n\n");
-
- fprintf(fp,"256 1 8\n");
- fprintf(fp,"[256 0 0 1 0 0]\n");
- fprintf(fp,"{currentfile\n sclstr readhexstring pop}\nimage\n");
- for(i=255;i>=0;i--)
- {
- fprintf(fp,"%02.2x",i);
- if((i%16)==0) fprintf(fp,"\n");
- }
- fprintf(fp,"showpage\n");
- fprintf(fp,"\n");
-
-
- fclose(fp);
-
-
- scrollDown(gScreen,180);
- CloseWindow(progwin);
-
- return(1);
- }
-
-