예제 #1
0
ImageDescriptionArray JPEGInstance::Open( const String& filePath, const IsoString& hints )
{
   Close();

   try
   {
      Exception::EnableConsoleOutput();

      JPEGImageOptions jpegOptions = JPEGFormat::DefaultOptions();
      IsoStringList theHints;
      hints.Break( theHints, ' ', true/*trim*/ );
      theHints.Remove( IsoString() );
      for ( IsoStringList::const_iterator i = theHints.Begin(); i < theHints.End(); ++i )
         if ( *i == "verbosity" )
         {
            if ( ++i == theHints.End() )
               break;
            int n;
            if ( i->TryToInt( n ) )
               jpegOptions.verbosity = Range( n, 0, 3 );
         }

      m_reader = new JPEGReader;
      m_reader->SetJPEGOptions( jpegOptions );
      m_reader->Open( filePath );
      return ImageDescriptionArray() << ImageDescription( m_reader->Info(), m_reader->Options() );
   }
   catch ( ... )
   {
      Close();
      throw;
   }
}
예제 #2
0
void JPEGInstance::Create( const String& filePath, int numberOfImages, const IsoString& hints )
{
   Close();

   Exception::EnableConsoleOutput();

   m_writer = new JPEGWriter;
   m_writer->Create( filePath );

   JPEGImageOptions jpegOptions = JPEGFormat::DefaultOptions();

   IsoStringList theHints;
   hints.Break( theHints, ' ', true/*trim*/ );
   theHints.Remove( IsoString() );
   for ( IsoStringList::const_iterator i = theHints.Begin(); i < theHints.End(); ++i )
   {
      if ( *i == "quality" )
      {
         if ( ++i == theHints.End() )
            break;
         int q = jpegOptions.quality;
         if ( i->TryToInt( q ) )
            jpegOptions.quality = Range( q, 0, 100 );
      }
      else if ( *i == "optimized" )
         jpegOptions.optimizedCoding = true;
      else if ( *i == "no-optimized" )
         jpegOptions.optimizedCoding = false;
      else if ( *i == "arithmetic" )
         jpegOptions.arithmeticCoding = true;
      else if ( *i == "huffman" )
         jpegOptions.arithmeticCoding = false;
      else if ( *i == "progressive" )
         jpegOptions.progressive = true;
      else if ( *i == "no-progressive" )
         jpegOptions.progressive = false;
      else if ( *i == "verbosity" )
      {
         if ( ++i == theHints.End() )
            break;
         int n;
         if ( i->TryToInt( n ) )
            jpegOptions.verbosity = Range( n, 0, 3 );
      }
   }

   m_writer->SetJPEGOptions( jpegOptions );
}
예제 #3
0
void JPCInstance::Create( const String& filePath, int/*numberOfImages*/, const IsoString& hints )
{
   Close();

   Exception::EnableConsoleOutput();

   m_path = filePath;

   IsoStringList theHints;
   hints.Break( theHints, ' ', true/*trim*/ );
   theHints.Remove( IsoString() );
   for ( IsoStringList::const_iterator i = theHints.Begin(); i < theHints.End(); ++i )
   {
      if ( *i == "lossy" )
         m_jp2Options.lossyCompression = true;
      else if ( *i == "lossless" )
         m_jp2Options.lossyCompression = false;
      else if ( *i == "compression-rate" )
      {
         if ( ++i == theHints.End() )
            break;
         if ( i->TryToFloat( m_jp2Options.compressionRate ) )
            m_jp2Options.compressionRate = Range( m_jp2Options.compressionRate, 0.01F, 0.99F );
      }
      else if ( *i == "signed" )
         m_jp2Options.signedSample = true;
      else if ( *i == "unsigned" )
         m_jp2Options.signedSample = false;
      else if ( *i == "tiled" )
         m_jp2Options.tiledImage = true;
      else if ( *i == "untiled" )
         m_jp2Options.tiledImage = true;
      else if ( *i == "tile-width" )
      {
         if ( ++i == theHints.End() )
            break;
         if ( i->TryToInt( m_jp2Options.tileWidth ) )
            m_jp2Options.tileWidth = Range( m_jp2Options.tileWidth, 16, 8192 );
      }
      else if ( *i == "tile-height" )
      {
         if ( ++i == theHints.End() )
            break;
         if ( i->TryToInt( m_jp2Options.tileHeight ) )
            m_jp2Options.tileHeight = Range( m_jp2Options.tileHeight, 16, 8192 );
      }
      else if ( *i == "layers" )
      {
         if ( ++i == theHints.End() )
            break;
         if ( i->TryToInt( m_jp2Options.numberOfLayers ) )
            m_jp2Options.numberOfLayers = Range( m_jp2Options.numberOfLayers, 1, 10 );
      }
      else if ( *i == "lrcp" )
         m_jp2Options.progressionOrder = JPEG2000ProgressionOrder::LRCP;
      else if ( *i == "rlcp" )
         m_jp2Options.progressionOrder = JPEG2000ProgressionOrder::RLCP;
      else if ( *i == "rpcl" )
         m_jp2Options.progressionOrder = JPEG2000ProgressionOrder::RPCL;
      else if ( *i == "pcrl" )
         m_jp2Options.progressionOrder = JPEG2000ProgressionOrder::PCRL;
      else if ( *i == "cprl" )
         m_jp2Options.progressionOrder = JPEG2000ProgressionOrder::CPRL;
   }
}