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

void IWPixmap::Encode::init ( const GPixmap bm,
const GP< GBitmap mask = 0,
CRCBMode  crcbmode = CRCBnormal 

Initializes an IWPixmap with color image bm#. This constructor performs the wavelet decomposition of image bm# and records the corresponding wavelet coefficient. Argument mask# is an optional bilevel image specifying the masked pixels (see {IW44Image.h}). Argument crcbmode# specifies how the chrominance information should be encoded (see {CRCBMode}).

Definition at line 1579 of file IW44EncodeCodec.cpp.

References close_codec(), GPixmap::columns(), GPixmap::rows(), GPixmap::rowsize(), and GBitmap::rowsize().

Referenced by IW44Image::create_encode().

  /* Free */
  delete ymap;
  delete cbmap;
  delete crmap;
  ymap = cbmap = crmap = 0;
  /* Create */
  int w = pm.columns();
  int h = pm.rows();
  signed char *buffer;
  GPBuffer<signed char> gbuffer(buffer,w*h);
  // Create maps
  Map::Encode *eymap = new Map::Encode(w,h);
  ymap = eymap;
  // Handle CRCB mode
  switch (crcbmode) 
    case CRCBnone:   crcb_half=1; crcb_delay=-1; break;
    case CRCBhalf:   crcb_half=1; crcb_delay=10; break;        
    case CRCBnormal: crcb_half=0; crcb_delay=10; break;
    case CRCBfull:   crcb_half=0; crcb_delay= 0; break;
  // Prepare mask information
  const signed char *msk8 = 0;
  int mskrowsize = 0;
  GBitmap *mask=gmask;
  if (mask)
    msk8 = (signed char const *)((*mask)[0]);
    mskrowsize = mask->rowsize();
  // Fill buffer with luminance information
  DJVU_PROGRESS_TASK(create,"initialize pixmap",3);
  DJVU_PROGRESS_RUN(create,(crcb_delay>=0 ? 1 : 3));
  Transform::Encode::RGB_to_Y(pm[0], w, h, pm.rowsize(), buffer, w);
  if (crcb_delay < 0)
      // Stupid inversion for gray images
      signed char *e = buffer + w*h;
      for (signed char *b=buffer; b<e; b++)
        *b = 255 - *b;
  // Create YMAP
  eymap->create(buffer, w, msk8, mskrowsize);
  // Create chrominance maps
  if (crcb_delay >= 0)
      Map::Encode *ecbmap = new Map::Encode(w,h);
      cbmap = ecbmap;
      Map::Encode *ecrmap = new Map::Encode(w,h);
      crmap = ecrmap;
      // Process CB information
      Transform::Encode::RGB_to_Cb(pm[0], w, h, pm.rowsize(), buffer, w);
      ecbmap->create(buffer, w, msk8, mskrowsize);
      // Process CR information
      Transform::Encode::RGB_to_Cr(pm[0], w, h, pm.rowsize(), buffer, w); 
      ecrmap->create(buffer, w, msk8, mskrowsize);
      // Perform chrominance reduction (CRCBhalf)
      if (crcb_half)

Generated by  Doxygen 1.6.0   Back to index