Logo Search packages:      
Sourcecode: djvulibre version File versions

void GBitmap::save_rle ( ByteStream bs  ) 

Saves the image into ByteStream bs# using the RLE file format. The image is saved as a bilevel image. All non zero pixels are considered black pixels. See section {PNM and RLE file formats}.

Definition at line 985 of file GBitmap.cpp.

References GUTF8String::format(), GBaseString::length(), monitor(), and ByteStream::writall().

{
  // checks
  if (ncolumns==0 || nrows==0)
    G_THROW( ERR_MSG("GBitmap.not_init") );
  GMonitorLock lock(monitor());
  if (grays > 2)
    G_THROW( ERR_MSG("GBitmap.cant_make_PBM") );
  // header
  GUTF8String head;
  head.format("R4\n%d %d\n", ncolumns, nrows);
  bs.writall((void*)(const char *)head, head.length());
  // body
  if (rle)
    {
      bs.writall((void*)rle, rlelength);
    }
  else
    {
      unsigned char *runs = 0;
      GPBuffer<unsigned char> gruns(runs);
      int size = encode(runs,gruns);
      bs.writall((void*)runs, size);
    }
}


Generated by  Doxygen 1.6.0   Back to index