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

Drawing & Stream::readerPng ( const QByteArray &  pngRawBytes,
bool  decodeFromBase64 = false 
) [static]

Convert a Fortified-PNG image into a drawing.

If the PNG image or the ISF data within it are invalid, or if the PNG did not have any ISF stream within, then a null Drawing is returned.

Parameters:
gifRawBytesSource byte array with a Fortified PNG image
decodeFromBase64True if the bytes are in the Base64 format and need to be decoded first
Returns:
an Isf::Drawing, with null contents on error

Definition at line 326 of file isfqt.cpp.

{
  QByteArray isfData;

#ifdef ISFQT_DEBUG_VERBOSE
  qDebug() << "Reading a PNG-Fortified file";
#endif

  QByteArray pngBytes( decodeFromBase64
                        ? QByteArray::fromBase64( pngRawBytes )
                        : pngRawBytes );

  QImage imageData( QImage::fromData( pngBytes, "PNG" ) );
  if( ! imageData.isNull() )
  {
#ifdef ISFQT_DEBUG_VERBOSE
    qDebug() << "Picture data is valid: checking for the ISF data tag...";
#endif
    isfData = imageData.text( "application/x-ms-ink" ).toAscii();

    if( ! isfData.isEmpty() )
    {
#ifdef ISFQT_DEBUG_VERBOSE
      qDebug() << "ISF data found! Decoding from Base64 and parsing it...";
#endif
      isfData = QByteArray::fromBase64( isfData );
    }
  }

  return reader( isfData );
}

Generated by  Doxygen 1.6.0   Back to index