本文整理汇总了C++中OutputStream::flush方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputStream::flush方法的具体用法?C++ OutputStream::flush怎么用?C++ OutputStream::flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputStream
的用法示例。
在下文中一共展示了OutputStream::flush方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _compositeOutputStreamFlush
void _compositeOutputStreamFlush(OutputStream* outputStream) {
int i;
CompositeOutputStream* compositeOutputStream = getCompositeOutputStream(outputStream);
int size = compositeOutputStream->size;
for (i = 0; i < size; i++) {
OutputStream* childOutputStream = getChildOutputStream(compositeOutputStream, i);
childOutputStream->flush(childOutputStream);
}
}
示例2: pipeStream
void pipeStream(InputStream &source, OutputStream &dest)
{
for (;;)
{
int ch = source.get();
if (ch<0)
break;
dest.put(ch);
}
dest.flush();
}
示例3: write
void BufferedConnectionWriter::write(OutputStream& os)
{
stopWrite();
for (size_t i = 0; i < header_used; i++) {
yarp::os::ManagedBytes& b = *(header[i]);
os.write(b.usedBytes());
}
for (size_t i = 0; i < lst_used; i++) {
yarp::os::ManagedBytes& b = *(lst[i]);
os.write(b.usedBytes());
}
os.flush();
}
示例4: save_image
void save_image(Image::ConstRefArg image, OutputStream& out,
std::string target_name, std::string format_name,
Logger* logger, FileFormat::ProgressTracker* tracker,
FileFormat::Registry::ConstRefArg r)
{
FileFormat::Registry::ConstRef registry = r;
if (!registry)
registry = FileFormat::Registry::get_default_registry();
if (format_name.empty()) {
// Determine format by suffix
std::string suffix = ascii_tolower(file::suffix_of(target_name));
if (!suffix.empty()) {
for (int i = 0; i < registry->get_num_formats(); ++i) {
FileFormat::ConstRef f = registry->get_format(i);
if (!f->check_suffix(suffix))
continue;
format_name = f->get_name();
break;
}
}
}
if (format_name.empty()) {
throw UnresolvableFormatException("Image format could not be "
"detected from the file name"
": \"" + target_name + "\"");
}
for (int i = 0; i < registry->get_num_formats(); ++i) {
FileFormat::ConstRef f = registry->get_format(i);
if (format_name != f->get_name())
continue;
f->save(image, out, logger, tracker);
out.flush();
return;
}
throw UnknownFormatException("Unrecognized format "
"specifier: \""+format_name+"\"");
}
示例5: save
void Command::save(OutputStream& stream) const {
stream.writeUint8(playerID);
stream.writeUint32((Uint32) commandID);
stream.writeUint32Vector(parameter);
stream.flush();
}
示例6: writeImageToStream
bool JPEGImageFormat::writeImageToStream (const Image& image, OutputStream& out)
{
using namespace jpeglibNamespace;
using namespace JPEGHelpers;
if (image.hasAlphaChannel())
{
// this method could fill the background in white and still save the image..
jassertfalse;
return true;
}
struct jpeg_compress_struct jpegCompStruct;
struct jpeg_error_mgr jerr;
setupSilentErrorHandler (jerr);
jpegCompStruct.err = &jerr;
jpeg_create_compress (&jpegCompStruct);
JuceJpegDest dest;
jpegCompStruct.dest = &dest;
dest.output = &out;
HeapBlock <char> tempBuffer (jpegBufferSize);
dest.buffer = tempBuffer;
dest.next_output_byte = (JOCTET*) dest.buffer;
dest.free_in_buffer = jpegBufferSize;
dest.init_destination = jpegWriteInit;
dest.empty_output_buffer = jpegWriteFlush;
dest.term_destination = jpegWriteTerminate;
jpegCompStruct.image_width = image.getWidth();
jpegCompStruct.image_height = image.getHeight();
jpegCompStruct.input_components = 3;
jpegCompStruct.in_color_space = JCS_RGB;
jpegCompStruct.write_JFIF_header = 1;
jpegCompStruct.X_density = 72;
jpegCompStruct.Y_density = 72;
jpeg_set_defaults (&jpegCompStruct);
jpegCompStruct.dct_method = JDCT_FLOAT;
jpegCompStruct.optimize_coding = 1;
//jpegCompStruct.smoothing_factor = 10;
if (quality < 0.0f)
quality = 0.85f;
jpeg_set_quality (&jpegCompStruct, jlimit (0, 100, roundToInt (quality * 100.0f)), TRUE);
jpeg_start_compress (&jpegCompStruct, TRUE);
const int strideBytes = jpegCompStruct.image_width * jpegCompStruct.input_components;
JSAMPARRAY buffer = (*jpegCompStruct.mem->alloc_sarray) ((j_common_ptr) &jpegCompStruct,
JPOOL_IMAGE, strideBytes, 1);
const Image::BitmapData srcData (image, Image::BitmapData::readOnly);
while (jpegCompStruct.next_scanline < jpegCompStruct.image_height)
{
const uint8* src = srcData.getLinePointer (jpegCompStruct.next_scanline);
uint8* dst = *buffer;
for (int i = jpegCompStruct.image_width; --i >= 0;)
{
*dst++ = ((const PixelRGB*) src)->getRed();
*dst++ = ((const PixelRGB*) src)->getGreen();
*dst++ = ((const PixelRGB*) src)->getBlue();
src += srcData.pixelStride;
}
jpeg_write_scanlines (&jpegCompStruct, buffer, 1);
}
jpeg_finish_compress (&jpegCompStruct);
jpeg_destroy_compress (&jpegCompStruct);
out.flush();
return true;
}
示例7: writeImageToStream
bool PNGImageFormat::writeImageToStream (const Image& image, OutputStream& out)
{
using namespace pnglibNamespace;
const int width = image.getWidth();
const int height = image.getHeight();
png_structp pngWriteStruct = png_create_write_struct (PNG_LIBPNG_VER_STRING, 0, 0, 0);
if (pngWriteStruct == 0)
return false;
png_infop pngInfoStruct = png_create_info_struct (pngWriteStruct);
if (pngInfoStruct == 0)
{
png_destroy_write_struct (&pngWriteStruct, (png_infopp) 0);
return false;
}
png_set_write_fn (pngWriteStruct, &out, PNGHelpers::writeDataCallback, 0);
png_set_IHDR (pngWriteStruct, pngInfoStruct, width, height, 8,
image.hasAlphaChannel() ? PNG_COLOR_TYPE_RGB_ALPHA
: PNG_COLOR_TYPE_RGB,
PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE,
PNG_FILTER_TYPE_BASE);
HeapBlock <uint8> rowData (width * 4);
png_color_8 sig_bit;
sig_bit.red = 8;
sig_bit.green = 8;
sig_bit.blue = 8;
sig_bit.alpha = 8;
png_set_sBIT (pngWriteStruct, pngInfoStruct, &sig_bit);
png_write_info (pngWriteStruct, pngInfoStruct);
png_set_shift (pngWriteStruct, &sig_bit);
png_set_packing (pngWriteStruct);
const Image::BitmapData srcData (image, Image::BitmapData::readOnly);
for (int y = 0; y < height; ++y)
{
uint8* dst = rowData;
const uint8* src = srcData.getLinePointer (y);
if (image.hasAlphaChannel())
{
for (int i = width; --i >= 0;)
{
PixelARGB p (*(const PixelARGB*) src);
p.unpremultiply();
*dst++ = p.getRed();
*dst++ = p.getGreen();
*dst++ = p.getBlue();
*dst++ = p.getAlpha();
src += srcData.pixelStride;
}
}
else
{
for (int i = width; --i >= 0;)
{
*dst++ = ((const PixelRGB*) src)->getRed();
*dst++ = ((const PixelRGB*) src)->getGreen();
*dst++ = ((const PixelRGB*) src)->getBlue();
src += srcData.pixelStride;
}
}
png_bytep rowPtr = rowData;
png_write_rows (pngWriteStruct, &rowPtr, 1);
}
png_write_end (pngWriteStruct, pngInfoStruct);
png_destroy_write_struct (&pngWriteStruct, &pngInfoStruct);
out.flush();
return true;
}