本文整理汇总了C++中std::ofstream::width方法的典型用法代码示例。如果您正苦于以下问题:C++ ofstream::width方法的具体用法?C++ ofstream::width怎么用?C++ ofstream::width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::ofstream
的用法示例。
在下文中一共展示了ofstream::width方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveDisplaySettingsModeTable
void CDisplaySettingsList::SaveDisplaySettingsModeTable( std::ofstream &stream )
{
CDisplaySettingsList videomodelist;
CDisplaySettingsList pixelsizelist;
CDisplaySettingsList displayfreqlist;
CDisplaySettings temp, *pptr;
char buffer[128], padline[128], padspace[128], padtop[128];
static int padtable[6] = { 0, 28, 14, 9, 5 };
static char title[] = "Display Frequencies";
int newfreq, freq, len;
unsigned int padlen;
for (unsigned int pn = 0; pn < size(); pn++ )
{
pptr = &at(pn);
newfreq = at(pn).m_pelswidth *
at(pn).m_pelsheight *
at(pn).m_displayvertfreq;
if ( newfreq > m_maxfreq )
{
m_maxfreq = newfreq;
}
// Generate list of unique video resolutions
if ( videomodelist.FindDisplaySetting(
pptr->m_pelswidth, pptr->m_pelsheight, -1, -1 ) == NULL )
{
videomodelist.push_back( *pptr );
}
// Generate list of pixel sizes
if ( pixelsizelist.FindDisplaySetting(
-1, -1, pptr->m_bitsperpel, -1 ) == NULL )
{
pixelsizelist.push_back( *pptr );
}
// Generate list of display frequencies
if ( displayfreqlist.FindDisplaySetting(
-1, -1, -1, pptr->m_displayvertfreq ) == NULL )
{
displayfreqlist.push_back( *pptr );
}
}
pixelsizelist.SetSortMode( LIST_SORTBITSPERPEL );
pixelsizelist.Sort();
stream << std::endl << std::endl;
stream << "Display modes" << std::endl;
stream << "-------------" << std::endl << std::endl;
stream << "Maximum bandwidth: " << m_maxfreq << " Hertz" << std::endl;
if ( displayfreqlist.size() < 5)
{
padlen = padtable[ displayfreqlist.size()];
}
else
{
padlen = 5;
}
for (unsigned int pn = 0; pn < padlen; pn++ )
{
padline[pn] = '-';
padtop[pn] = '-';
padspace[pn] = ' ';
}
padline[padlen] = '+';
padline[padlen+1] = '\0';
padspace[padlen] = '\0';
padtop[padlen] = '-';
padtop[padlen+1] = '\0';
for (unsigned int qn = 0; qn < pixelsizelist.size(); qn++ )
{
stream << std::endl << std::endl;
stream << "Pixel size: " << pixelsizelist[qn].m_bitsperpel << " bits" << std::endl;
stream << "-------------------" << std::endl << std::endl;
// ------ Top line
stream << " +";
for (unsigned int pn = 0; pn < displayfreqlist.size()-1; pn++ )
{
stream << padtop;
}
stream << padline;
stream << std::endl;
// ------ Display frequencies
//.........这里部分代码省略.........
示例2: saveImagesToDisk
void saveImagesToDisk(ros::NodeHandle& nh, ros::Subscriber& sub)
{
//pcl::ScopeTime t1 ("save images");
{
boost::mutex::scoped_lock lock(rgb_mutex_);
memcpy( cv_rgb_.data, &rgb_data_[0], 3*rows_*cols_*sizeof(unsigned char));
new_rgb_ = false;
}
capture_->stop();
sub.shutdown();
sub = nh.subscribe("/camera/depth/image_raw", 1, &OpenNIShoter::frameDepthCallback, this);
new_depth_ = false;
capture_->start();
do
{
if (new_depth_ == true )
{
boost::mutex::scoped_lock lock(depth_mutex_);
memcpy( cv_depth_.data, &depth_data_[0], rows_*cols_*sizeof(uint16_t));
new_depth_ = false;
break;
}
boost::this_thread::sleep (boost::posix_time::millisec (10));
} while (1);
capture_->stop();
sub.shutdown();
sub = nh.subscribe("/camera/ir/image", 1, &OpenNIShoter::frameIRCallback, this);
new_ir_ = false;
capture_->start();
do
{
if (new_ir_ == true )
{
boost::mutex::scoped_lock lock(ir_mutex_);
memcpy( cv_ir_raw_.data, &ir_data_[0], rows_*cols_*sizeof(uint16_t));
cv_ir_raw_.convertTo(cv_ir_, CV_8U);
cv::equalizeHist( cv_ir_, cv_ir_ );
int max = 0;
for (int i=0; i< rows_; i++)
{
for (int j=0; j< cols_; j++)
{
if (ir_data_[i+j*rows_] > max)
max = ir_data_[i+j*rows_];
}
}
std::cout << "max IR val: " << max << std::endl;
new_ir_ = false;
break;
}
boost::this_thread::sleep (boost::posix_time::millisec (10));
} while (1);
capture_->stop();
sub.shutdown();
sub = nh.subscribe("/camera/rgb/image_raw", 1, &OpenNIShoter::frameRGBCallback, this);
capture_->start();
sprintf(depth_file, "/Depth/%018ld.png", timestamp_depth_ );
sprintf(rgb_file, "/RGB/%018ld.png", timestamp_rgb_);
sprintf(ir_file, "/IR/%018ld.png", timestamp_ir_);
cv::imwrite( write_folder_ + depth_file, cv_depth_);
cv::imwrite( write_folder_ + rgb_file, cv_rgb_);
cv::imwrite( write_folder_ + ir_file, cv_ir_);
sprintf(depth_file_PNG, "/Depth/%018ld.png", timestamp_depth_);
sprintf(rgb_file_PNG, "/RGB/%018ld.png", timestamp_rgb_);
sprintf(ir_file_PNG, "/IR/%018ld.png", timestamp_ir_);
off_rgb_.width(18);
off_rgb_.fill('0');
off_rgb_ << timestamp_rgb_;
off_rgb_ << " " << rgb_file_PNG << std::endl;
off_depth_.width(18);
off_depth_.fill('0');
off_depth_ << timestamp_depth_;
off_depth_ << " " << depth_file_PNG << std::endl;
off_ir_.width(18);
off_ir_.fill('0');
off_ir_ << timestamp_ir_;
//.........这里部分代码省略.........
示例3: SaveDisplaySettingsList
void CDisplaySettingsList::SaveDisplaySettingsList( std::ofstream &stream )
{
char buffer[1024];
//stream.setmode( filebuf::text );
stream << "Display Settings List" << std::endl;
stream << "---------------------" << std::endl << std::endl;
stream << "No. of display settings [" << size() << "] ";
stream << "Sorted by [";
switch (m_sortmode & ~LIST_SORTREVERSED)
{
case LIST_SORTINDEX:
stream << "Index";
break;
case LIST_SORTBITSPERPEL:
stream << "Depth";
break;
case LIST_SORTPELSWIDTH:
stream << "Width";
break;
case LIST_SORTPELSHEIGHT:
stream << "Height";
break;
case LIST_SORTDISPLAYFLAGS:
stream << "Flags";
break;
case LIST_SORTDISPLAYVERTFREQ:
stream << "Vert Refresh";
break;
case LIST_SORTDISPLAYHORIZFREQ:
stream << "Horiz Refresh";
break;
case LIST_SORTDISPLAYBANDWIDTH:
stream << "Bandwidth";
break;
default:
break;
}
stream << "]";
stream << " Reversed ";
if ( m_sortmode & LIST_SORTREVERSED )
{
stream << "[@]";
}
else
{
stream << "[ ]";
}
stream << std::endl << std::endl;
stream << "+-------+-------+--------+--------+-----------+-----------+" << std::endl;
stream << "| Index | BPP | Width | Height | Frequency | Bandwidth |" << std::endl;
stream << "+-------+-------+--------+--------+-----------+-----------+" << std::endl;
for ( unsigned int pn = 0; pn < size(); pn++ )
{
stream << "| ";
stream.width( 5 );
stream << at(pn).m_index << " ";
stream << " | ";
stream.width( 5 );
stream << at(pn).m_bitsperpel; // Pixel size
stream << " | ";
stream.width( 6 );
stream << at(pn).m_pelswidth; // Display width
stream << " | ";
stream.width( 6 );
stream << at(pn).m_pelsheight; // Display height
stream << " | ";
stream.width( 8 );
stream << std::hex;
// stream.pad( '0');
stream << at(pn).m_displayflags;
stream << " | ";
stream.width( 9 );
if ( at(pn).m_displayvertfreq == 0 ||
at(pn).m_displayvertfreq == 1 )
{
//.........这里部分代码省略.........