⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ximage.c

📁 su 的源代码库
💻 C
📖 第 1 页 / 共 4 页
字号:
			        (nxb>nx)) {ixb=0;nxb=nx;				           x2begb=x2beg;					   x2endb=x2end;}     			   if (czb!=cz) free1(czb);			   czb = ealloc1(nxb*nyb,				     sizeof(signed char));			   for (i=0,czbp=czb; i<nyb; i++) {			       czp = cz+(iyb+i)*nx+ixb;			       for (j=0; j<nxb; j++)				    *czbp++ = *czp++; 			   }									  				  /* clear area and force an expose event */			  XClearArea(dpy,win,0,0,0,0,True);			  /* note that image is out of date */			  imageOutOfDate = 1;											} else if (keysym==XK_Down ) {			  /* move zoom box down by half window height */			  mve = (x1endb - x1begb)/mvefac ;			  x1begb = x1begb + mve ;			  x1endb = x1endb + mve ;			  msg="move "; 			  /* check for bounds of full window */			  if (x1endb > x1end){			    if ( lock ) { x1begb = x1begb - mve ;			                  x1endb = x1endb - mve ;					  msg="limit ";					  mve=0;			    } else { x1endb = x1end;			             nyb=(int)((x1endb-x1begb)/dy);				   }			  }			  if (verbose) fprintf(stderr,"%s %g\n",msg,mve);			   iyb+=(int)(mve/dy);			   			   /* reset to original if out of range */			   if ( (iyb<0) || 			        ((iyb+nyb)>ny) || 			        (nyb<2) || 			        (nyb>ny)) {iyb=0;nyb=ny;				           x1begb=x1beg;					   x1endb=x1end;}			  /* clear area and force an expose event */			  XClearArea(dpy,win,0,0,0,0,True);			  /* note that image is out of date */			  imageOutOfDate = 1;     			   if (czb!=cz) free1(czb);			   czb = ealloc1(nxb*nyb,				     sizeof(signed char));			   for (i=0,czbp=czb; i<nyb; i++) {			       czp = cz+(iyb+i)*nx+ixb;			       for (j=0; j<nxb; j++)				    *czbp++ = *czp++; 			   }									} else if (keysym==XK_Up || keysym==XK_KP_Up ) {			  /*********** 			   * move zoom box up in .... vertical* 			   ***********                          */			  mve = (x1endb - x1begb)/mvefac ;			  x1begb = x1begb - mve ;			  x1endb = x1endb - mve ;			  msg="move "; 			  /* check for bounds of full window */			  if (x1begb < x1beg){			    if ( lock ) { x1begb = x1begb + mve ;			                  x1endb = x1endb + mve ;					  msg="limit ";					  mve=0;			    } else { x1begb = x1beg ;			             nyb=(int)((x1endb-x1begb)/dy);				   }			  }			  if (verbose) fprintf(stderr,"%s %g\n",msg,mve);			  iyb+=-(int)(mve/dy);			  			  /* reset to original if out of range */			   if ( (iyb<0) || 			        (nyb<2) || 			        (nyb>ny)) {iyb=0;nyb=ny;				           x1begb=x1beg;					   x1endb=x1end;}     			   if (czb!=cz) free1(czb);			   czb = ealloc1(nxb*nyb,				     sizeof(signed char));			   for (i=0,czbp=czb; i<nyb; i++) {			       czp = cz+(iyb+i)*nx+ixb;			       for (j=0; j<nxb; j++)				    *czbp++ = *czp++; 			   }													/* clear area and force an expose event */			XClearArea(dpy,win,0,0,0,0,True);						/* note that image is out of date */			imageOutOfDate = 1;												} else if (keysym==XK_o || keysym==XK_KP_Subtract ) {			  /*********** 			   *zoom out .... vertical* 			   ***********            */			  mve = (x1endb - x1begb)/mvefac ;			  x1begb = x1begb - mve ;			  x1endb = x1endb + mve ;			  /* check for bounds of full window */			  if (x1begb < x1beg){			    if ( lock ) { x1begb = x1begb + mve ;					  msg="limit ";					  mve=0;			    } else { x1begb = x1beg ;}			  }			  if (x1endb > x1end){			    if ( lock ) { x1endb = x1endb - mve ;					  msg="limit ";					  mve=0;			    } else { x1endb = x1end ;}			  } 		           nyb=(int)((x1endb-x1begb)/dy);			   iyb+=-(int)(mve/dy);			   if ( (iyb<0) || (nyb>ny)) {iyb=0;nyb=ny;}			  			  /*   .... and horizontal */			  mve = (x2endb - x2begb)/mvefac ;			  x2begb = x2begb - mve ;			  x2endb = x2endb + mve ;			  /* check bounds of original image */			  if (x2begb < x2beg){			    if ( lock ) { x2begb = x2begb + mve ;					  msg="limit ";					  mve=0;			    } else { x2begb = x2beg ;}			  }			  if (x2endb > x2end){			    if ( lock ) { x2endb = x2endb - mve ;					  msg="limit ";					  mve=0;			    } else { x2endb = x2end ;}			  }			   nxb=(int)((x2endb-x2begb)/dx);			   ixb+=-(int)(mve/dx); 			   if ( (ixb<0)        || 			        ((ixb+nxb)>nx) || 			        (nxb<0)        || 			        (nxb>nx))  { ixb=0;nxb=nx;				             x2begb=x2beg;					     x2endb=x2end;}			   			   if (czb!=cz) free1(czb);			   czb = ealloc1(nxb*nyb,				     sizeof(signed char));			   for (i=0,czbp=czb; i<nyb; i++) {			       czp = cz+(iyb+i)*nx+ixb;			       for (j=0; j<nxb; j++)				    *czbp++ = *czp++; 			   }			 				  /* clear area and force an expose event */		   	  XClearArea(dpy,win,0,0,0,0,True);			 			  /* note that image is out of date */			  imageOutOfDate = 1;											} else if (keysym==XK_i || keysym==XK_KP_Add ) {			  /*********** 			   *zoom in .... vertical* 			   ***********           */			  mve = (x1endb - x1begb)/(2.*mvefac) ;			  x1begb = x1begb + mve ;			  x1endb = x1endb - mve ;			   iyb+=(int)(mve/dy);			  /*   .... and horizontal */			  mve = (x2endb - x2begb)/(2.*mvefac) ;			  x2begb = x2begb + mve ;			  x2endb = x2endb - mve ;			   ixb+=(int)(mve/dx);			   nxb=(int)((x2endb-x2begb)/dx);			   nyb=(int)((x1endb-x1begb)/dy);			   if ( (ixb<0) || 			        (nxb>nx)||				(ixb>nx)||				(nxb<0) ) {ixb=0;nxb=nx;				             x2begb=x2beg;					     x2endb=x2end;}			   if ( (iyb<0) || 			        (nyb>ny)||				(iyb>ny)||				(nyb<0) ) {iyb=0;nyb=ny;				             x1begb=x1beg;					     x1endb=x1end;}			  /* clear area and force an expose event */			  XClearArea(dpy,win,0,0,0,0,True);			 			  /* note that image is out of date */			  imageOutOfDate = 1;			if (czb!=cz) free1(czb);					czb = ealloc1(nxb*nyb,						sizeof(signed char));					for (i=0,czbp=czb; i<nyb; i++) {					    czp = cz+(iyb+i)*nx+ixb;					    for (j=0; j<nxb; j++)						    *czbp++ = *czp++; 					}								} else if (keysym==XK_c || keysym==XK_Page_Down) {		  						/* Change clip for image */ 		       		clip += clip/10. ;				if (verbose) warn("clip=%g\n",clip); 				/* note that image is out of date */				 imageOutOfDate = 1;								 			} else if (keysym==XK_a || keysym==XK_Page_Up) {				/* Change clip for image */			        clip -= clip/10. ;				if (verbose) warn("clip=%g\n",clip);				/* note that image is out of date */				imageOutOfDate = 1;								if (czb!=cz) free1(czb);					czb = ealloc1(nxb*nyb,						sizeof(signed char));					for (i=0,czbp=czb; i<nyb; i++) {					    czp = cz+(iyb+i)*nx+ixb;					    for (j=0; j<nxb; j++)						    *czbp++ = *czp++; 					}							/* end of section for moving clipping and zooming GK */		    			} else if (keysym==XK_q || keysym==XK_Q) {			/* This is the exit from the event loop */				break;			} else if (keysym==XK_p || keysym==XK_P) {			/* invoke pswigb with appropriate data */				char *cmdline, cmdtemp[256];				float cmdfloat;				int iargc;				FILE *plotfp;	/*fp for plot data*/									cmdline = (char *) emalloc(BUFSIZ);								strcpy(cmdline,"psimage");				for(iargc = 1; iargc < argc; iargc++) {					strcat(cmdline," ");					strcat(cmdline,argv[iargc]);					}				/* override incompatible arguments */				sprintf(cmdtemp," axescolor=%s",labelcolor);				strcat(cmdline,cmdtemp);				cmdfloat = DisplayWidthMM(dpy,scr)/25.4;				cmdfloat /= DisplayWidth(dpy,scr);				sprintf(cmdtemp," wbox=%g", cmdfloat*width);				strcat(cmdline,cmdtemp);				sprintf(cmdtemp," xbox=%g", 0.5+cmdfloat*xbox);				strcat(cmdline,cmdtemp);				cmdfloat = DisplayHeightMM(dpy,scr)/25.4;				cmdfloat /= DisplayHeight(dpy,scr);				sprintf(cmdtemp," hbox=%g", cmdfloat*height);				strcat(cmdline,cmdtemp);				sprintf(cmdtemp," ybox=%g", 0.5+cmdfloat*ybox);				strcat(cmdline,cmdtemp);				sprintf(cmdtemp," x1beg=%g", x1begb);				strcat(cmdline,cmdtemp);				sprintf(cmdtemp," x1end=%g",x1endb);				strcat(cmdline,cmdtemp);				sprintf(cmdtemp," x2beg=%g", x2begb);				strcat(cmdline,cmdtemp);				sprintf(cmdtemp," x2end=%g",x2endb);				strcat(cmdline,cmdtemp);				if (STREQ(cmap,"gray")) {					strcat(cmdline," brgb=0.0,0.0,0.0");					strcat(cmdline," wrgb=1.0,1.0,1.0");					}				else if (STREQ(cmap,"hue")) {					strcat(cmdline," bhls=0.75,0.5,1.0");					strcat(cmdline," whls=0.0,0.5,1.0");					}				strcat(cmdline," title=\"");				strcat(cmdline,title);				strcat(cmdline,"\"");				strcat(cmdline," label1=\"");				strcat(cmdline,label1);				strcat(cmdline,"\"");				strcat(cmdline," label2=\"");				strcat(cmdline,label2);				strcat(cmdline,"\"");				sprintf(cmdtemp," > %s ", plotfile);				strcat(cmdline,cmdtemp);				fprintf(stderr,"%i * %i = %i\n",n1,n2,nz);				fprintf(stderr,"%s\n",cmdline);                                /* pipe data to psimage and write to plotfile *GK*/				plotfp = epopen(cmdline, "w");				free(cmdline);				efwrite(z,sizeof(float),nz,plotfp);				epclose(plotfp);							} else if (keysym==XK_r) {				Colormap mycp=xCreateRGBColormap(dpy,win,"rgb_up",verbose);				XSetWindowColormap(dpy,win,mycp);				XInstallColormap(dpy,mycp);                                /* clear area and force an expose event */                                XClearArea(dpy,win,0,0,0,0,True);                                /* note that image is out of date */                                imageOutOfDate = 1;			} else if (keysym==XK_R) {                                Colormap mycp=xCreateRGBColormap(dpy,win,"rgb_down",verbose);                                XSetWindowColormap(dpy,win,mycp);				XInstallColormap(dpy,mycp);                                /* clear area and force an expose event */                                XClearArea(dpy,win,0,0,0,0,True);                                /* note that image is out of date */                                imageOutOfDate = 1;			} else if (keysym==XK_h) {                                Colormap mycp=xCreateHSVColormap(dpy,win,"hsv_up",verbose);                                XSetWindowColormap(dpy,win,mycp);				XInstallColormap(dpy,mycp);                                /* clear area and force an expose event */                                XClearArea(dpy,win,0,0,0,0,True);                                /* note that image is out of date */                                imageOutOfDate = 1;			} else if (keysym==XK_H) {                                Colormap mycp=xCreateHSVColormap(dpy,win,"hsv_down",verbose);                                                                XSetWindowColormap(dpy,win,mycp);				XInstallColormap(dpy,mycp);                                /* clear area and force an expose event */                                XClearArea(dpy,win,0,0,0,0,True);                                /* note that image is out of date */                                imageOutOfDate = 1;			} else {				continue;			}		/* else if button down (1 == zoom, 2 == mouse tracking */		} else if (event.type==ButtonPress) {			/* if 1st button: zoom */			if (event.xbutton.button==Button1) {				/* track pointer and get new box */				xRubberBox(dpy,win,event,&xb,&yb,&wb,&hb);							/* if new box has tiny width or height */				if (wb<4 || hb<4) {									/* reset box to initial values */					x1begb = x1beg;					x1endb = x1end;					x2begb = x2beg;					x2endb = x2end;					nxb = nx;					nyb = ny;					ixb = iyb = 0;					if (czb!=cz) free1(czb);					czb = cz;							/* else, if new box has non-zero width */				/* and height */				} else {								/* calculate new box parameters */					if (style==NORMAL) {					    zoomBox(x,y,width,height,						    xb,yb,wb,hb,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -