Logo Search packages:      
Sourcecode: djvulibre version File versions

int DjVuImage::is_legal_compound (  )  const

This function returns true if this object contains a well formed {Compound DjVu Image}. Calling function get_bitmap# or get_pixmap# on a well formed compound DjVu image should always return a non zero value. Note that functions get_bitmap# or get_pixmap# works as soon as sufficient information is present, regardless of the fact that the image follows the rules or not.

Definition at line 596 of file DjVuImage.cpp.

References get_bg44(), get_bgpm(), get_fgbc(), get_fgjb(), get_fgpm(), and get_info().

  // Components
  GP<DjVuInfo>     info = get_info();
  GP<JB2Image>     fgjb = get_fgjb();
  GP<IW44Image>     bg44 = get_bg44();
  GP<GPixmap>      bgpm = get_bgpm();
  GP<GPixmap>      fgpm = get_fgpm();
  GP<DjVuPalette>  fgbc = get_fgbc();
  // Check size
  if (! info)
    return 0;
  int width = info->width;
  int height = info->height;
  if (! (width>0 && height>0))
    return 0;
  // Check fgjb
  if (!fgjb)
    return 0;
  if (fgjb->get_width()!=width || fgjb->get_height()!=height)
    return 0;
  // Check background
  int bgred = 0;
  if (bg44)
    bgred = compute_red(width, height, bg44->get_width(), bg44->get_height());
  else if (bgpm)
    bgred = compute_red(width, height, bgpm->columns(), bgpm->rows());
  if (bgred<1 || bgred>12)
    return 0;
  // Check foreground colors
  int fgred = 0;
  if (fgbc)
    fgred = 1;
  else if (fgpm)
    fgred = compute_red(width, height, fgpm->columns(), fgpm->rows());
  if (fgred<1 || fgred>12)
    return 0;
  // Check that all components are present
  if (fgjb && bgred && fgred)
    return 1;
  // Unrecognized
  return 0;

Generated by  Doxygen 1.6.0   Back to index