Пример #1
0
uint32_t
bigToNativeUInt32(uint32_t i)
{
	if(getEndianness() != ENDIANNESS_BIG)
		return swapUInt(i);

	return i;
}
Пример #2
0
uint16_t
bigToNativeUInt16(uint16_t s)
{
	if(getEndianness() != ENDIANNESS_BIG)
		return swapUShort(s);

	return s;
}
Пример #3
0
int16_t
littleToNativeInt16(int16_t s)
{
	if(getEndianness() == ENDIANNESS_BIG)
		return swapShort(s);

	return s;
}
Пример #4
0
float
bigToNativeFloat(float f)
{
	if(getEndianness() != ENDIANNESS_BIG)
		return swapFloat(f);

	return f;
}
Пример #5
0
uint32_t
littleToNativeUInt32(uint32_t i)
{
	if(getEndianness() == ENDIANNESS_BIG)
		return swapUInt(i);

	return i;
}
Пример #6
0
float
littleToNativeFloat(float f)
{
	if(getEndianness() == ENDIANNESS_BIG)
		return swapFloat(f);

	return f;
}
Пример #7
0
void
Camera::serialize(BinaryOutputStream & output, Codec const & codec) const
{
  output.setEndianness(getEndianness());

  output.writeCoordinateFrame3(frame);
  output.writeUInt8(projection_type == ProjectionType::ORTHOGRAPHIC ? 0 : 1);
  output.writeFloat32(static_cast<float32>(left));
  output.writeFloat32(static_cast<float32>(right));
  output.writeFloat32(static_cast<float32>(bottom));
  output.writeFloat32(static_cast<float32>(top));
  output.writeFloat32(static_cast<float32>(near_dist));
  output.writeFloat32(static_cast<float32>(far_dist));

  output.writeUInt8(proj_y_dir == ProjectedYDirection::UP ? 0 : 1);
}
Пример #8
0
void
Camera::deserialize(BinaryInputStream & input, Codec const & codec)
{
  input.setEndianness(getEndianness());

  frame = input.readCoordinateFrame3();

  uint8 pt = input.readUInt8();
  projection_type = (pt == 0 ? ProjectionType::ORTHOGRAPHIC : ProjectionType::PERSPECTIVE);

  left       =  static_cast<Real>(input.readFloat32());
  right      =  static_cast<Real>(input.readFloat32());
  bottom     =  static_cast<Real>(input.readFloat32());
  top        =  static_cast<Real>(input.readFloat32());
  near_dist  =  static_cast<Real>(input.readFloat32());
  far_dist   =  static_cast<Real>(input.readFloat32());

  uint8 pyd = input.readUInt8();
  proj_y_dir = (pyd == 0 ? ProjectedYDirection::UP : ProjectedYDirection::DOWN);
}
Пример #9
0
bool SequenceOutput::CloseINRFile() {
    static const char INR_HEADER_START[]=\
         "#INRIMAGE-4#{\n"\
         "XDIM=%d\n"\
         "YDIM=%d\n"\
         "ZDIM=%d\n"\
         "VDIM=1\n"\
         "VX=%g\n"\
         "VY=%g\n"\
         "VZ=1\n"\
         "TYPE=double\n"\
         "PIXSIZE=%lu bits\n"\
         "SCALE=2**0\n"\
         "CPU=%s\n"; // INR header start
    static const char INR_HEADER_END[]="\n##}\n"; // chars at the End of INR header
    bool ret_correct;
    char inr_header[INR_HEADER_LEN];
    int n_printed_chars;
         
    snprintf(inr_header, INR_HEADER_LEN, INR_HEADER_START, sizeY, sizeX, num_written_frames, Voxel_X_size, Voxel_Y_size, sizeof(double)*8, getEndianness()); // popullate header buffer
    n_printed_chars = strlen(inr_header); // snprintf must always write a \0 char, so we can use strlen safely
    memset(inr_header+n_printed_chars, ' ', INR_HEADER_LEN-n_printed_chars); // Pad the remaining header buffer with spaces to fill the space which is not used
    memcpy(inr_header+INR_HEADER_LEN-(sizeof(INR_HEADER_END)-1), INR_HEADER_END, sizeof(INR_HEADER_END)-1); // Write the last part of the header

    out_seq_file_handle.seekp(0, ios::beg); // rewind put file pointer
    out_seq_file_handle.write(inr_header, INR_HEADER_LEN); // Write INR header

    ret_correct = out_seq_file_handle.good();
    out_seq_file_handle.close();
    
    return(ret_correct);
}