コード例 #1
0
ファイル: clip.c プロジェクト: Shirling-VT/VTRST3.5
int SplotClip(struct Splot *ptr,
              int num,float *px,float *py,int *t) {

  int s=0;
  if (ptr==NULL) return -1;
  if (ptr->ps.ptr !=NULL) {
    struct PostScript *ps;
    ps=ptr->ps.ptr;
    if (ptr->ps.clip !=NULL) PostScriptFreeClip(ptr->ps.clip);
    ptr->ps.clip=NULL;
    if (num==0) return 0;
    ptr->ps.clip=PostScriptMakeClip(ps->x,ps->y,ps->wdt,ps->hgt,num,px,py,t);
    if (ptr->ps.clip==NULL) s=-1;
  }
  if (ptr->fb.ptr !=NULL) {
    int *ix=NULL,*iy=NULL;
    int i;
    struct FrameBuffer *img;
    img=*(ptr->fb.ptr);
    if (img==NULL) return -1;

    if (ptr->fb.clip !=NULL) FrameBufferFreeClip(ptr->fb.clip);
    ptr->fb.clip=NULL;
    if (num==0) return 0;

    ix=malloc(sizeof(int)*num);
    if (ix==NULL) return -1;
    iy=malloc(sizeof(int)*num);
    if (iy==NULL) {
      free(ix);
      return -1;
    }
    for (i=0;i<num;i++) {
      ix[i]=px[i];
      iy[i]=py[i];
    }

    ptr->fb.clip=FrameBufferMakeClip(img->wdt,img->hgt,num,ix,iy,t);
    if (ptr->fb.clip==NULL) s=-1;
    free(ix);
    free(iy);
  }



  return s;
} 
コード例 #2
0
ファイル: clip.c プロジェクト: ajribeiro/VT_RST3
struct FrameBufferClip *fbclip(int wdt,int hgt) {

  int i;
  float sf=0.55;
  int px[12];
  int py[12];
  int t[12];

  px[0]=0.5*wdt;
  py[0]=0;
  px[1]=0.5*wdt;
  py[1]=0.5*hgt*sf;
  px[2]=0.5*wdt*sf;
  py[2]=0.5*hgt;
  px[3]=0;
  py[3]=0.5*hgt;
  px[4]=-0.5*wdt*sf;
  py[4]=0.5*hgt;
  px[5]=-0.5*wdt;
  py[5]=0.5*hgt*sf;
  px[6]=-0.5*wdt;
  py[6]=0;
  px[7]=-0.5*wdt;
  py[7]=-0.5*hgt*sf;
  px[8]=-0.5*wdt*sf;
  py[8]=-0.5*hgt;
  px[9]=0;
  py[9]=-0.5*hgt;
  px[10]=0.5*wdt*sf;
  py[10]=-0.5*hgt;
  px[11]=0.5*wdt;
  py[11]=-0.5*hgt*sf;

  for (i=0;i<12;i++) {
    t[i]=1;
    px[i]+=0.5*wdt;
    py[i]+=0.5*hgt;
  }
  return FrameBufferMakeClip(wdt,hgt,12,px,py,t);
}