Пример #1
0
static void ImageSwapEndian(IMAGE *I)
{
  DCPIX  *dcpix, dcval ;
  CPIX   *cpix, cval ;
  double *dpix, dval ;
  float  *fpix, fval ;
  long   npix ;

  npix = (long)I->numpix * (long)I->num_frame ;

  switch (I->pixel_format)
  {
  case PFDBLCOM:
    dcpix = IMAGEDCpix(I, 0, 0) ;
    while (npix--)
    {
      dcval = *dcpix ;
      dcpix->real = swapDouble(dcval.real) ;
      dcpix->imag = swapDouble(dcval.imag) ;
      dcpix++ ;
    }
    break ;
  case PFCOMPLEX:
    cpix = IMAGECpix(I, 0, 0) ;
    while (npix--)
    {
      cval = *cpix ;
      cpix->real = swapFloat(cval.real) ;
      cpix->imag = swapFloat(cval.imag) ;
      cpix++ ;
    }
    break ;
  case PFDOUBLE:
    dpix = IMAGEDpix(I, 0, 0) ;
    while (npix--)
    {
      dval = *dpix ;
      *dpix++ = swapDouble(dval) ;
    }
    break ;
  case PFFLOAT:
    fpix = IMAGEFpix(I, 0, 0) ;
    while (npix--)
    {
      fval = *fpix ;
      *fpix++ = swapFloat(fval) ;
    }
    break ;
  default:
    ErrorExit(ERROR_UNSUPPORTED,"ImageFRead: unsupported type %d\n",
              I->pixel_format);
  }
}
Пример #2
0
//-----------------------------------------------------------------------------
void PDCFileWriter::write3vector(ofstream &outfile, const double x1, const double y1, const double z1)
{
	//writes a 3-column data vector to the file: use this for data type 5
	double x = x1;
	double y = y1;
	double z = z1;

	swapDouble((char*) &x);
	swapDouble((char*) &y);
	swapDouble((char*) &z);

	outfile.write((char*) &x, sizeof(double));
	outfile.write((char*) &y, sizeof(double));
	outfile.write((char*) &z, sizeof(double));
}
Пример #3
0
//-----------------------------------------------------------------------------
void PDCFileWriter::write1scalar(ofstream &outfile, const double x1)
{
	//writes a 1-column data scalar/number to the file: use this for data type 3
	double x = x1;
	swapDouble((char*) &x);
	outfile.write((char*) &x,sizeof(double));
}
Пример #4
0
// --------------------------------------------------------------------------
//! convert table of double (little endian/big endian)
// --------------------------------------------------------------------------
void XipTreeRequestManager::rSwapd(double* tabDouble, int sizeTab)
{
	//only swap if big endian architecture
	#if defined(WINDOWS) || defined(_WIN32)
		return;
	#else
		if(BYTE_ORDER == 1234)
			return;
	#endif

	int i;
	for(i=0; i< sizeTab; i++)
	{
		tabDouble[i] = swapDouble(tabDouble[i]);
	}
}
Пример #5
0
double doubleConvertHost2Net(double dw) {
    if(isHostBigEndian) return dw;
    return swapDouble(dw);
}