Logo Search packages:      
Sourcecode: djvulibre version File versions

void DjVuImage::decode ( ByteStream str,
DjVuInterface *  notifier = 0 
)

This function is here for backward compatibility. Now, with the introduction of multipage DjVu documents, the decoding is handled by {DjVuFile} and {DjVuDocument} classes. For single page documents though, we still have this wrapper.

Definition at line 504 of file DjVuImage.cpp.

References DataPool::create(), DjVuDocument::create_wait(), ByteStream::EndOfFile, and ByteStream::read().

{
  DEBUG_MSG("DjVuImage::decode(): decoding old way...\n");
  DEBUG_MAKE_INDENT(3);
  if (file) 
    G_THROW( ERR_MSG("DjVuImage.bad_call") );
  GP<DjVuImageNotifier> pport = new DjVuImageNotifier(notifier);
  pport->stream_url=GURL::UTF8("internal://fake/fake.djvu");
  pport->stream_pool=DataPool::create();
  // Get all the data first
  int length;
  char buffer[1024];
  while((length=str.read(buffer, 1024)))
    pport->stream_pool->add_data(buffer, length);
  pport->stream_pool->set_eof();
  GP<DjVuDocument> doc = DjVuDocument::create_wait(pport->stream_url, (DjVuImageNotifier*)pport);
  GP<DjVuImage> dimg=doc->get_page(-1, true, (DjVuImageNotifier*)pport);
  file=dimg->get_djvu_file();
  if (file->is_decode_stopped())
    G_THROW( DataPool::Stop );
  if (file->is_decode_failed())
    G_THROW( ByteStream::EndOfFile ); // guess
  if (!file->is_decode_ok())
    G_THROW( ERR_MSG("DjVuImage.mult_error") );
  DEBUG_MSG("decode DONE\n");
}


Generated by  Doxygen 1.6.0   Back to index