Logo Search packages:      
Sourcecode: kmess version File versions  Download package

QByteArray Stream::writer ( const Drawing drawing,
bool  encodeToBase64 = false 
) [static]

Convert a drawing into a raw ISF data stream.

The resulting byte array will be empty if the drawing is not valid.

Parameters:
drawingSource drawing
encodeToBase64Whether the converted ISF stream should be encoded with Base64 or not
Returns:
Byte array with an ISF data stream

Definition at line 382 of file isfqt.cpp.

References Isf::TagsWriter::addAttributeTable(), Isf::TagsWriter::addHiMetricSize(), Isf::TagsWriter::addMetricsTable(), Isf::TagsWriter::addPersistentFormat(), Isf::TagsWriter::addStrokes(), Isf::TagsWriter::addTransformationTable(), Isf::Drawing::error(), Isf::ISF_ERROR_NONE, Isf::Drawing::isNull(), and Isf::TagsWriter::prepare().

Referenced by Isf::InkCanvas::bytes(), and Isf::InkCanvas::save().

{
  if( &drawing == 0 || drawing.isNull() || drawing.error() != ISF_ERROR_NONE )
  {
#ifdef ISFQT_DEBUG
    qDebug() << "The drawing was not valid!";
#endif
    return QByteArray();
  }

  streamData_ = new StreamData();
  streamData_->dataSource = new DataSource();
  DataSource* dataSource = streamData_->dataSource;

  // Add the initial data
  TagsWriter::prepare( streamData_, &drawing );

  // Write the persistent format tag
  TagsWriter::addPersistentFormat( streamData_, &drawing );

  // Write the drawing size
  TagsWriter::addHiMetricSize( streamData_, &drawing );

  // Write the attributes
  TagsWriter::addAttributeTable( streamData_, &drawing );

  // Write the metrics
  TagsWriter::addMetricsTable( streamData_, &drawing );

  // Write the transforms
  TagsWriter::addTransformationTable( streamData_, &drawing );

  // Write the strokes
  TagsWriter::addStrokes( streamData_, &drawing );

  // Write the stream size (at the start of the stream)
  encodeUInt( dataSource, dataSource->size(), true/*prepend*/ );

  // Write the version number (at the start of the stream)
  encodeUInt( dataSource, SUPPORTED_ISF_VERSION, true/*prepend*/ );

  QByteArray data( dataSource->data() );

  delete streamData_->dataSource;
  delete streamData_;
  streamData_ = 0;

  // Convert to Base64 if needed
  if( encodeToBase64 )
  {
    return data.toBase64();
  }
  else
  {
    return data;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index