double HeikenAshi(int tf,int price,int bar)
{ 
   //if(bar == iBars(NULL,TimeFrame)- 1) 
//if(bar == chartbars[displayedfile]- 1) 
if(bar == 666- 1) 
   {
   haClose[bar] = iclose(tf,bar);
   haOpen[bar]  = iopen(tf,bar);
   haHigh[bar]  = ihigh(tf,bar);
   haLow[bar]   = ilow(tf,bar);
   }
   else
   {
   haClose[bar] = (iopen(tf,bar)+ihigh(tf,bar)+ilow(tf,bar)+iclose(tf,bar))/4;
   haOpen[bar]  = (haOpen[bar+1]+haClose[bar+1])/2;
   haHigh[bar]  = mathmax(ihigh(tf,bar),mathmax(haOpen[bar], haClose[bar]));
   haLow[bar]   = mathmin(ilow(tf,bar),mathmin(haOpen[bar], haClose[bar]));
   }
   
   switch(price)
   {
   case 0: return(haClose[bar]);break;
   case 1: return(haOpen[bar]);break;
   case 2: return(haHigh[bar]);break;
   case 3: return(haLow[bar]);break;
   }
}     
Example #2
0
File: rowSGI.c Project: sprax/coldz
void
sgiWritFB(ppf rgb[4], int dX, int dY, unt dW, unt dH, unt dD, char *path)
{
IMAGE   *sgim;
int     k,y,yI;
flt	*sr, *sg, *sb ;
pus     dr, dg, db, rr, gg, bb;

  mallocAss(rr,ush,dW);
  mallocAss(gg,ush,dW);
  mallocAss(bb,ush,dW);

  wrn("sgiWritFB dD: %u  path: %s", dD,path);

  if (dD < 3 || rgb[1] == NULL) {
    sgiWritFlt(rgb[0],dX,dY,dW,dH,path);
    return;
  }
  sgim = iopen(path,"w",RLE(1),3,dW,dH,3);  /* WHAT'S the 1st 3? */
  for (y = 0, yI = dH+dY; yI > dY ; y++) {
    sr = &rgb[1][--yI][dX];
    sg = &rgb[2][  yI][dX];
    sb = &rgb[3][  yI][dX];
    for (dr = rr, dg = gg, db = bb, k = dW; k; k--) {    
      *dr++ = 0.5F + *sr++;
      *dg++ = 0.5F + *sg++;
      *db++ = 0.5F + *sb++;
    }
    putrow(sgim,rr,y,0);
    putrow(sgim,gg,y,1);
    putrow(sgim,bb,y,2);
  }
  iclose(sgim); free(rr); free(gg); free(bb);
}
Example #3
0
File: socket.c Project: kvirund/mmc
static int  iwrite(int s,void *ptr,size_t count) {
    int	    result;

    if (s<0 || s>=NSOCK || !sockets[s].inuse)
	return -1;
    if (!count)
	return 0;
    if (sockets[s].type==RT_SOCK)
      result=send(sockets[s].sock,ptr,count,0);
    else
#ifdef WIN32
    {
      DWORD nw;
      if (WriteFile((HANDLE)sockets[s].sock,ptr,count,&nw,NULL))
	result=nw;
      else
	result=-1;
    }
#else
      result=write(sockets[s].sock,ptr,count);
#endif
    if (result<=0)
	iclose(s);
    sockets[s].rawout+=result;
    return result;
}
Example #4
0
File: socket.c Project: kvirund/mmc
static void sofinish(int s) {
  int	    opt;
  socklen_t optlen;

  optlen=sizeof(opt);
  if (getsockopt(sockets[s].sock,SOL_SOCKET,SO_ERROR,(char*)&opt,&optlen)<0)
    FAIL("getsockopt failed");
  if (opt) {
#ifdef WIN32
    WSASetLastError(opt);
#else
    errno=opt;
#endif
    FAIL("can't connect to remote host");
  }
#if 0
  /*  this code was stolen from some other tcp/ip app, looks like this is
      needed for some ancient SunOS, should do no harm on other OSes */
  if (connect(sockets[s].sock,(struct sockaddr *)&sockets[s].remote,sizeof(sockets[s].remote))<0 &&
	    errno!=EISCONN) {
    read(sockets[s].sock,&opt,1);
    FAIL("can't connect to remote host");
  }
#endif
  if (sockets[s].handler)
    sockets[s].handler(s,SCONN,sockets[s].data,NULL,0);
  sockets[s].mode=sockets[s].opmode;
  return;
er:
  if (sockets[s].handler)
    sockets[s].handler(s,SIOERR,sockets[s].data,NULL,0);
  iclose(s);
}
Example #5
0
void saveSGIImage(char *name, int doAlphaToo)
{
    IMAGE *img;
    FILE *fp;
    GLubyte *pixels; 
    int x, y;
    int numComp = doAlphaToo ? 4 : 3;

    pixels = malloc(winWidth * winHeight * numComp * sizeof(GLubyte));

    glReadPixels(0, 0, winWidth, winHeight, doAlphaToo ? GL_RGBA : GL_RGB,
        GL_UNSIGNED_BYTE, pixels);

    img = iopen(name, "w", RLE(1), numComp, winWidth, winHeight, numComp);

    for(y = 0; y < winHeight; y++) {
        for(x = 0; x < winWidth; x++) {
	    rrow[x] = pixels[(y * winWidth + x) * numComp + 0];
	    grow[x] = pixels[(y * winWidth + x) * numComp + 1];
	    brow[x] = pixels[(y * winWidth + x) * numComp + 2];
	    if(doAlphaToo)
		arow[x] = pixels[(y * winWidth + x) * numComp + 3];
	}
        putrow(img, rrow, y, 0);
        putrow(img, grow, y, 1);
        putrow(img, brow, y, 2);
	if(doAlphaToo)
	    putrow(img, arow, y, 3);
    }
    iclose(img);

    free(pixels);
}
Example #6
0
File: socket.c Project: kvirund/mmc
static int  iread(int s,void *ptr,size_t count) {
    int	    result;

    if (s<0 || s>=NSOCK || !sockets[s].inuse)
	return -1;
    if (!count)
	return 0;
    if (sockets[s].type==RT_SOCK)
      result=recv(sockets[s].sock,ptr,count,0);
    else
#ifdef WIN32
    {
      DWORD   nr;
      if (ReadFile((HANDLE)sockets[s].sock,ptr,count,&nr,NULL))
	result=nr;
      else
	result=-1;
    }
#else
      result=read(sockets[s].sock,ptr,count);
#endif
    if (result<=0)
	iclose(s);
    sockets[s].rawin+=result;
    return result;
}
Example #7
0
File: rowSGI.c Project: sprax/coldz
void
sgiWritUB(ppu rgb[4], unt dW, unt dH, char *path)
{
IMAGE   *sgim;
int     k,y,yI;
unc	*sr, *sg, *sb ;
ush     *dr, *dg, *db, rr[512], gg[512], bb[512];

  assert(dW <= 512);
  sgim = iopen(path,"w",RLE(1),3,dW,dH,3);  /* WHAT'S the 1st 3? */
  for (y = 0, yI = dH; yI ; y++) {
    sr = rgb[1][--yI];
    sg = rgb[2][  yI];
    sb = rgb[3][  yI];
    for (dr = rr, dg = gg, db = bb, k = dW; k; k--) {    
      *dr++ = *sr++;
      *dg++ = *sg++;
      *db++ = *sb++;
    }
    putrow(sgim,rr,y,0);
    putrow(sgim,gg,y,1);
    putrow(sgim,bb,y,2);
  }
  iclose(sgim);
}
void WBSDCalibrateCanisterwindow::closeEvent(QCloseEvent *)
{
    ParameterMsg gmsg1(Message::MCB,Message::DV,ParameterMsg::SET_PARAMETER);
    gmsg1.setNibble(0,0);
    itsBaseWindow->addMessageToQue(gmsg1);
    theSpeed=0;
    emit iclose();
}
Example #9
0
File: socket.c Project: kvirund/mmc
void	sclose(int s) {
    if (s<0 || s>=NSOCK || !sockets[s].inuse)
	return;
    if (soflush(s)<0)
	return;
    sockets[s].handler(s,SCLOSED,sockets[s].data,NULL,0);
    iclose(s);
    if (sockets[s].inuse==2)
      sockets[s].inuse=0;
}
Example #10
0
File: socket.c Project: kvirund/mmc
static void start_mccp(int s) {
  z_stream  *zp;

  if ((zp=(z_stream*)malloc(sizeof(z_stream)))==NULL) {
    clerrx("Out of memory!");
    sockets[s].handler(s,SIOERR,sockets[s].data,NULL,0);
    iclose(s);
    return;
  }
  memset(zp,0,sizeof(*zp));
  if (inflateInit(zp)!=Z_OK) {
    clerrx("zlib initialization error");
    iclose(s);
    free(zp);
    return;
  }
  sockets[s].zsp=zp;
  clmsg("Starting MCCP.");
}
Example #11
0
File: rowSGI.c Project: sprax/coldz
unt
sgiRead4U (ppu ret[4], unt *dW, unt *dH, int oX, int oY, char *path, unt flags)
{
IMAGE   *sgim;
ush 	*rowbuf;
unt     sW,sH,sD;
size_t	rsize;
int     y, yI;

  if ( ! (sgim=iopen(path,"r")))
    die("sgiRead4U: iopen(%s) failed\n",path);
  sW = sgim->xsize;
  sH = sgim->ysize;
  sD = sgim->zsize;

  rsize = sizeof(unsigned short)*sW*sD;
  if (! (rowbuf  = (unsigned short *)malloc(rsize)))
    die("sgiRead4U(%s): malloc(%u)",path,rsize);

  sH -= oY;  *dH = sH;
  sW -= oX;  *dW = sW;

  switch (sD) {
    case  1: { ppu dst;
      ret[0] = dst = rowMalUnc(0,0,sW,sH);
      ret[1] = NULL;
      for (yI = sH, y = oY; yI ; y++) {
        getrow(sgim,rowbuf,y,1);
        uncUsh(dst[--yI],rowbuf+oX,sW);
      }
    } break;
    case  3: { ppu gry, red, grn, blu;
      ret[0] = gry = rowMalUnc(0,0,sW,sH);
      ret[1] = red = rowMalUnc(0,0,sW,sH);
      ret[2] = grn = rowMalUnc(0,0,sW,sH);
      ret[3] = blu = rowMalUnc(0,0,sW,sH);
      /***** ret[4] = NULL; *****/
      for (yI = sH, y = oY; yI-- ; y++) {
        getrow(sgim,   rowbuf, y, 0);
        uncUsh(red[yI],rowbuf+oX,sW);
        getrow(sgim,   rowbuf, y, 1);
        uncUsh(grn[yI],rowbuf+oX,sW);
        getrow(sgim,   rowbuf, y, 2);
        uncUsh(blu[yI],rowbuf+oX,sW);
      }
      gryRgbUnc(gry,red,grn,blu,0,0,sW,sH);
    } break;
    default: die("sgiRead4U [%s]: NOIMP for SGI image depth %u",__FILE__,sD);
  }
  free(rowbuf);
  iclose(sgim);
  if      (sD == 3) return 4;
  else if (sD <= 1) return 1;
  else              return 0;
}
Example #12
0
/*
 * An error occurred; save the message for later printing,
 * close open files, and reset to main command loop.
 */
void
error(char *n)
{
	errmsg = n;
	iclose(0, 1);
	oclose();
	flush();
	delbp();
	ending = 0;
	longjmp(env, 1);
}
Example #13
0
File: isis.c Project: bloovis/isis
isis()
{
    BYTE opcode;

    if ((WORD)savepc != 0x41)			/* not an ISIS-II call?	*/
    {
	monitor();			/* must be an MDS monitor call */
	return;
    }
    switch(savebc & 0xff)   /* it's an ISIS-II trap - do the right thing */
    {
	case 0:
	    iopen((OBLK *)savede);	/* OPEN call */
	    break;
	case 1:
	    iclose((CBLK *)savede);	/* CLOSE call */
	    break;
	case 2:
	    idelete((DBLK *)savede);	/* DELETE call */
	    break;
	case 3:
	    iread((RBLK *)savede);	/* READ call */
	    break;
	case 4:
	    iwrite((WBLK *)savede);	/* WRITE call */
	    break;
	case 5:
	    iseek((SBLK *)savede);	/* SEEK call */
	    break;
	case 6:
	    iload((LBLK *)savede);	/* LOAD call */
	    break;
	case 7:
	    irename((RNBLK *)savede);	/* RENAME call */
	    break;
	case 9:
	    cleanup();
	    break;
	case 11:
	    irescan((RSBLK *)savede);	/* RESCAN call */
	    break;
	case 12:		/* ERROR call */
	    ierror((EBLK *)savede);
	    break;
	case 14:		/* SPATH call */
	    ispath((SPBLK *)savede);
	    break;
	default:
	    print("\r\nIllegal ISIS-II function call ");
	    phexw(savebc);
	    print("\r\n");
	    break;
    }
}
Example #14
0
File: rowSGI.c Project: sprax/coldz
unt
sgiReadU( ppu *ret, unt *dW, unt *dH
	, int oX, int oY, unt mW, unt mH, char *path, unt flags)
{
IMAGE   *sgim;
ush     *rowbuf;
unt     sW,sH,sD;
int     y, yI;

  if ( ! (sgim=iopen(path,"r")))
    die("sgiReadU: iopen(%s) failed\n",path);

  sW = sgim->xsize;
  sH = sgim->ysize;
  sD = sgim->zsize;

  yI = sizeof(unsigned short)*sW*sD;
  mallocAss(rowbuf,ush,yI);

  sW -= oX;  if (sW > mW)  sW = mW;  *dW = sW;
  sH -= oY;  if (sH > mH)  sH = mH;  *dH = sH;

  switch (sD) {
    case  1: { ppu dst;
      ret[0] = dst = rowMalUnc(0,0,sW,sH);
      /***** ret[1] = NULL; *****/
      for (yI = sH, y = oY; yI ; y++) {
        getrow(sgim,rowbuf,y,1);
        uncUsh(dst[--yI],rowbuf+oX,sW);
      }
    } break;
    case  3: { ppu red, grn, blu;
      ret[0] = red = rowMalUnc(0,0,sW,sH);
      ret[1] = grn = rowMalUnc(0,0,sW,sH);
      ret[2] = blu = rowMalUnc(0,0,sW,sH);
      /***** ret[4] = NULL; *****/
      for (yI = sH, y = oY; yI-- ; y++) {
        getrow(sgim,   rowbuf, y, 0);
        uncUsh(red[yI],rowbuf+oX,sW);
        getrow(sgim,   rowbuf, y, 1);
        uncUsh(grn[yI],rowbuf+oX,sW);
        getrow(sgim,   rowbuf, y, 2);
        uncUsh(blu[yI],rowbuf+oX,sW);
      }
    } break;
    default: die("sgiReadU [%s]: NOIMP for SGI image depth %u",__FILE__,sD);
  }
  free(rowbuf);
  iclose(sgim);
  return sD;
}
Example #15
0
File: rowSGI.c Project: sprax/coldz
void
writSgiUsh(ppus rgb[4], unt dW, unt dH, char *path)
{
IMAGE   *sgim;
unt     y,yI;

  sgim = iopen(path,"w",RLE(1),3,dW,dH,3);  /* WHAT'S the 1st 3? */
  for (y = 0, yI = dH; yI-- ; y++) {
    putrow(sgim,rgb[1][yI],y,0);
    putrow(sgim,rgb[2][yI],y,1);
    putrow(sgim,rgb[3][yI],y,2);
  }
  iclose(sgim);
}
Example #16
0
File: rowSGI.c Project: sprax/coldz
unt
readSgiUsh
( ppus ret[4], unt *dW, unt *dH, int oX, int oY, char *path, unt flags )
{
IMAGE   *sgim;
unt     sW,sH,sD;
size_t  rsize;
int     y, yI;

  if ( ! (sgim=iopen(path,"r")))
    die("readSgiUsh: iopen(%s) failed\n",path);
  sW = sgim->xsize;
  sH = sgim->ysize;
  sD = sgim->zsize;

  rsize = sizeof(unsigned short)*sW*sD;

  sH -= oY;  *dH = sH;
  sW -= oX;  *dW = sW;

  switch (sD) {
    case  1: { ppus dst;
      ret[0] = dst = rowMalUsh(0,0,sW,sH);
      ret[1] = NULL;
      for (yI = sH, y = oY; yI ; y++)
        getrow(sgim,dst[--yI],y,1);
    } break;
    case  3: { ppus gry, red, grn, blu;
      ret[0] = gry = rowMalUsh(0,0,sW,sH);
      ret[1] = red = rowMalUsh(0,0,sW,sH);
      ret[2] = grn = rowMalUsh(0,0,sW,sH);
      ret[3] = blu = rowMalUsh(0,0,sW,sH);
      for (yI = sH, y = oY; yI-- ; y++) {
        getrow(sgim,  red[yI], y, 0);
        getrow(sgim,  grn[yI], y, 1);
        getrow(sgim,  blu[yI], y, 2);
      }
      gryRgbUsh(gry,red,grn,blu,sW,sH);
    } break;
    default: die("readSgiUsh [%s]: NOIMP for SGI image depth %u",__FILE__,sD);
  }
  iclose(sgim);
  if      (sD == 3) return 4;
  else if (sD <= 1) return 1;
  else              return 0;
}
Example #17
0
File: rowSGI.c Project: sprax/coldz
void
sgiWritFlt (ppf src, int sX, int sY, unt sW, unt sH, char *path)
{
  IMAGE *image;
  int k;
  unsigned short *rowp, *row;
  pfl srcp;

  if (! (image = iopen(path,"w",RLE(1),2,sW,sH)))
    die("sgiWritFlt: iopen(%s)", path);
  mallocAss(row,unsigned short,sW);
  for (src += sY; sH; ) {
    for (rowp = row, srcp = *src++ + sX, k = sW; k-- ; )
      *rowp++ = 0.5F + *srcp++;			/* Not IRINTF  */
    putrow(image,row,--sH,0);
  }
  iclose(image);
  free(row);
}
Example #18
0
File: rowSGI.c Project: sprax/coldz
int	/** replaced rowWriteSGIN **/
rowWritSGImU(ppu *srcU, int dX, int dY, unt dW, unt dH, unt chan, char *path)
{
ush     sbuf[1536];
ppu	srcp;
int     q,j,yI;
IMAGE   *sgim = iopen(path,"w",RLE(1),3,dW,dH,chan); 
  if (!sgim) {
    warn("rowWritSGImU: iopen failed");
    return -1;
  }
  for (q = 0; q < chan; q++) {
    for (srcp = &srcU[q][dY], j = dH, yI = dY; j-- ; ) {
      ushUnc(sbuf,*srcp++ + dX,dW);
      putrow(sgim,sbuf,j,q);
    }
  }
  return iclose(sgim);
}
Example #19
0
File: rowSGI.c Project: sprax/coldz
void
rowWriteSGI(ppf src, int sX, int sY, unt sW, unt sH, char *path)
{
IMAGE   *sgim;
int     k,y,yI;
flt	*fp;
ush     *up, *urow;

  mallocAss(urow,unsigned short,sW);
  sgim = iopen(path,"w",RLE(1),2,sW,sH,1);
  for (y = 0, yI = sH+sY; yI > sY ; y++) {
    fp = &src[--yI][sX];
    for (up = urow, k = sW; k-- ; ) {    
      *up++ = 0.5F + *fp++;
    }
    putrow(sgim,urow,y,0);
  }
  iclose(sgim);
}
Example #20
0
File: rowSGI.c Project: sprax/coldz
int	/* DOES NOT FLIP IMAGE AROUND X-AXIS -- ORIGIN AT BOTTOM LEFT */
rowWritSgiU(ppu *srcU, int dX, int dY, unt dW, unt dH, unt chan, char *path)
{
ush     sbuf[1024];
ppu	srcp;
int     j,q;
IMAGE   *sgim = iopen(path,"w",RLE(1),3,dW,dH,chan);

  if (!sgim) {
    warn("rowWritSgiU: iopen failed");
    return -1;
  }
  for (q = 0; q < chan; q++) {
    for (srcp = &srcU[q][dY], j = 0; j < dH; j++) {
      ushUnc(sbuf,*srcp++ + dX,dW);
      putrow(sgim, sbuf,j,q);
    }
  }
  return iclose(sgim);
  /* 0:success, -1:stdlib close err (check errno), EOF:sgi err */
}
Example #21
0
File: rowSGI.c Project: sprax/coldz
void
rowGraySGI (ppu src, int sX, int sY, unt sW, unt sH, char *path)
{
  IMAGE *image;
  int k;
  unsigned short *rowp, *row;
  puc ucp;

  mallocAss(row,unsigned short,sW);
  
  if (! (image = iopen(path,"w",RLE(1),2,sW,sH)))
    die("rowGraySGI: iopen(%s)", path);

  for (src += sY; sH; ) {
    for (rowp = row, ucp = *src++ + sX, k = 0; k < sW; k++)
      *rowp++ = *ucp++;
    putrow(image,row,--sH,0);
  }
  iclose(image);
  free(row);
}
Example #22
0
File: rowSGI.c Project: sprax/coldz
void *
rowReadSGI(char *path, unt *sW, unt *sH, unt *deep, unt flags)
{
IMAGE   *sgim;
ush 	*rowbuf;
void	*ret=NULL;
unt     xsize, ysize, zsize, y, yI, type = flags & MM_TYPE;
size_t	rsize;

  if ( ! (sgim=iopen(path,"r")))
    die("rowReadSGI: iopen(%s) failed\n",path);
  *sW = xsize = sgim->xsize;
  *sH = ysize = sgim->ysize;
  *deep = zsize = sgim->zsize;
  rsize = sizeof(unsigned short)*xsize*zsize;
  if (! (rowbuf  = (unsigned short *)malloc(rsize)))
    die("rowReadSGI(%s): malloc(%u)",path,rsize);
  switch (type) {
    case MM_UNC: {
      unc **dst = rowMalUnc(0,0,xsize,ysize);
      ret = dst;
      for (yI = ysize, y = 0; yI ; y++) {
        getrow(sgim,rowbuf,y,1);
        uncUsh(dst[--yI],rowbuf,xsize);
      }
    } break;
    case MM_FLT: {
      flt **dst = rowMalFlt(0,0,xsize,ysize);
      ret = dst;
      for (yI = ysize, y = 0; yI ; y++) {
        getrow(sgim,rowbuf,y,1);
        fltUsh(dst[--yI],rowbuf,xsize);
      }
    } break;
    default: die("rowReadSGI(%s): NOIMP for flags:%d",path,flags);
  }
  free(rowbuf);
  iclose(sgim);
  return ret;
}
Example #23
0
SbBool ReadSGIImage(const SoInput& in, int &w, int &h, int &nc,  
						unsigned char *&bytes) {

    i_seterror(errfunc);
    
    IMAGE *image_in;
    int i, j, row;

    if ( (image_in = fiopen(fileno(in.getCurFile()), "r")) == NULL)
	return FALSE;
	
    w = image_in->xsize;
    h = image_in->ysize;
    nc = image_in->zsize;

    bytes = new unsigned char[w*h*nc];

    short *rbuf = new short[w];

    int readOK = TRUE;

    for (row = 0; row < h; row++) {
	for (i = 0; i < nc; i++) {
	    if (getrow(image_in, rbuf, row, i) < 0) {
		row = h;  // Don't read any more rows
		readOK = FALSE;
		break;
	    }
	    for (j = 0; j < w; j++) {
		bytes[row*w*nc + j*nc + i] =
		    (unsigned char) rbuf[j];
	    }
	}
    }
    delete [] rbuf;

    iclose(image_in);
    
    return TRUE;
}
Example #24
0
File: rowSGI.c Project: sprax/coldz
void
rgbWriteSGIn(ppf rgb, int dX, int dY, unt dW, unt dH, char *path)
{
IMAGE   *sgim;
int     k,y;
flt     *sp;
ush     *rp, *gp, *bp, rr[1280], gg[1280], bb[1280];

  assert(dW <= 1280);
  sgim = iopen(path,"w",RLE(1),3,dW,dH,3);  /* WHAT'S the 1st 3? */
  for (rgb += dY, dX *= 3, y = 0; y < dH; y++) {
    sp = *rgb++ + dX;
    for (rp = rr, gp = gg, bp = bb, k = dW; k; k--) {
      *rp++ = 0.5F + *sp++;
      *gp++ = 0.5F + *sp++;
      *bp++ = 0.5F + *sp++;
    }
    putrow(sgim,rr,y,0);
    putrow(sgim,gg,y,1);
    putrow(sgim,bb,y,2);
  }
  iclose(sgim);
}
Example #25
0
File: rowSGI.c Project: sprax/coldz
void
rgbWriteSGI(ppf rgb, int dX, int dY, unt dW, unt dH, char *path)
{
IMAGE   *sgim;
int     k,y,yI;
flt	*sp;
ush     *rp, *gp, *bp, rr[1024], gg[1024], bb[1024];

  assert(dW <= 1024);
  sgim = iopen(path,"w",RLE(1),3,dW,dH,3);  /* WHAT'S the 1st 3? */
  for (dX *= 3, y = 0, yI = dH+dY; yI > dY ; y++) {
    sp = &rgb[--yI][dX];
    for (rp = rr, gp = gg, bp = bb, k = dW; k; k--) {    
      *rp++ = 0.5F + *sp++;
      *gp++ = 0.5F + *sp++;
      *bp++ = 0.5F + *sp++;
    }
    putrow(sgim,rr,y,0);
    putrow(sgim,gg,y,1);
    putrow(sgim,bb,y,2);
  }
  iclose(sgim);
}
Example #26
0
void WBSDpaytest::closeEvent(QCloseEvent *)
{
    emit iclose();
}
Example #27
0
void WBSDVersionWindow::closeEvent(QCloseEvent *)
{
    emit iclose();
}
Example #28
0
File: socket.c Project: kvirund/mmc
void soproc(int s,void *extbuf,int extlen) {
    unsigned char   rdbuf[16384],*ptr=rdbuf;
    int		    rdlen;
    int		    remain;

    if (sockets[s].mode==SM_CONN) {
      sofinish(s);
      if (sockets[s].inuse==2)
	sockets[s].inuse=0;
      return;
    }
    if (extbuf) {
      ptr=extbuf;
      rdlen=extlen;
      if (extlen<=0)
	iclose(s);
    } else
      rdlen=iread(s,rdbuf,sizeof(rdbuf));
    if (rdlen<0) {
	sockerrmsg("read from socket failed",0);
	sockets[s].handler(s,SIOERR,sockets[s].data,NULL,0);
    } else if (rdlen==0) {
	sockets[s].handler(s,SEOF,sockets[s].data,NULL,0);
    } else { /* got data, do mccp stuff now */
#ifdef LOGALLINPUT
    write(3,rdbuf,rdlen);
#endif
      while (rdlen>0) {
	remain=0;
	if (sockets[s].zsp) {
	  z_stream	*zp=sockets[s].zsp;
	  unsigned char	tmp[8192];
	  int		res;

	  zp->next_in=ptr;
	  zp->avail_in=rdlen;
	  while (zp->avail_in>0) {
	    zp->next_out=tmp;
	    zp->avail_out=sizeof(tmp);
	    res=inflate(zp,Z_SYNC_FLUSH);
	    if (res==Z_OK) {
	      if (zp->avail_out!=sizeof(tmp))
		remain=process_sockbuf(s,tmp,sizeof(tmp)-zp->avail_out);
	    } else if (res==Z_NEED_DICT) {
	      clerrx("Oops, zlib wants a dictionary, where can i find that, sir?");
	      sockets[s].handler(s,SIOERR,sockets[s].data,NULL,0);
	      iclose(s);
	      break;
	    } else if (res==Z_STREAM_END) {
	      if (zp->avail_out!=sizeof(tmp))
		remain=process_sockbuf(s,tmp,sizeof(tmp)-zp->avail_out);
	      remain=zp->avail_in;
	      inflateEnd(zp);
	      free(zp);
	      sockets[s].zsp=NULL;
	      clmsg("Stopping MCCP.");
	      break;
	    } else {
	      strcpy((char *)tmp,"zlib: ");
	      if (zp->msg)
		strncat((char *)tmp,zp->msg,sizeof(tmp));
	      else
		strncat((char *)tmp,"unknown error.",sizeof(tmp));
	      tmp[sizeof(tmp)-1]='\0';
	      clerrx((char *)tmp);
	      sockets[s].handler(s,SIOERR,sockets[s].data,NULL,0);
	      iclose(s);
	      break;
	    }
	  }
	} else
	  remain=process_sockbuf(s,ptr,(size_t)rdlen);
	ptr+=rdlen-remain;
	rdlen=remain;
      }
    }
    if (sockets[s].inuse==2)
      sockets[s].inuse=0;
}
TranslatedBootMedia::~TranslatedBootMedia()
{
    iclose();
	delete []imageBuffer;
}
Example #30
0
int
main(int argc, char* argv[])
{
	IMAGE *in;
	TIFF *out;
	int c;
	extern int optind;
	extern char* optarg;

	while ((c = getopt(argc, argv, "c:p:r:")) != -1)
		switch (c) {
		case 'c':		/* compression scheme */
			if (!processCompressOptions(optarg))
				usage();
			break;
		case 'f':		/* fill order */
			if (streq(optarg, "lsb2msb"))
				fillorder = FILLORDER_LSB2MSB;
			else if (streq(optarg, "msb2lsb"))
				fillorder = FILLORDER_MSB2LSB;
			else
				usage();
			break;
		case 'p':		/* planar configuration */
			if (streq(optarg, "separate"))
				config = PLANARCONFIG_SEPARATE;
			else if (streq(optarg, "contig"))
				config = PLANARCONFIG_CONTIG;
			else
				usage();
			break;
		case 'r':		/* rows/strip */
			rowsperstrip = atoi(optarg);
			break;
		case '?':
			usage();
			/*NOTREACHED*/
		}
	if (argc - optind != 2)
		usage();
	in = iopen(argv[optind], "r");
	if (in == NULL)
		return (-1);
	out = TIFFOpen(argv[optind+1], "w");
	if (out == NULL)
		return (-2);
	TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32) in->xsize);
	TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32) in->ysize);
	TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8);
	TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
	if (in->zsize == 1)
		photometric = PHOTOMETRIC_MINISBLACK;
	else
		photometric = PHOTOMETRIC_RGB;
	switch (compression) {
	case COMPRESSION_JPEG:
		if (photometric == PHOTOMETRIC_RGB && jpegcolormode == JPEGCOLORMODE_RGB)
			photometric = PHOTOMETRIC_YCBCR;
		TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality);
		TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode);
		break;
	case COMPRESSION_LZW:
	case COMPRESSION_DEFLATE:
		if (predictor != 0)
			TIFFSetField(out, TIFFTAG_PREDICTOR, predictor);
		break;
	}
	TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric);
	if (fillorder != 0)
		TIFFSetField(out, TIFFTAG_FILLORDER, fillorder);
	TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
	TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, in->zsize);
	if (in->zsize > 3) {
	    uint16 v[1];
	    v[0] = EXTRASAMPLE_UNASSALPHA;
	    TIFFSetField(out, TIFFTAG_EXTRASAMPLES, 1, v);
	}
	TIFFSetField(out, TIFFTAG_MINSAMPLEVALUE, (uint16) in->min);
	TIFFSetField(out, TIFFTAG_MAXSAMPLEVALUE, (uint16) in->max);
	TIFFSetField(out, TIFFTAG_PLANARCONFIG, config);
	if (config != PLANARCONFIG_SEPARATE)
		TIFFSetField(out, TIFFTAG_ROWSPERSTRIP,
		    TIFFDefaultStripSize(out, rowsperstrip));
	else			/* force 1 row/strip for library limitation */
		TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, 1L);
	if (in->name[0] != '\0')
		TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, in->name);
	if (config == PLANARCONFIG_CONTIG)
		cpContig(in, out);
	else
		cpSeparate(in, out);
	(void) iclose(in);
	(void) TIFFClose(out);
	return (0);
}