home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 110 / EnigmaAmiga110CD.iso / indispensabili / utility / apdf / xpdf-0.80 / xpdf / outputdev.cc < prev    next >
C/C++ Source or Header  |  1998-11-27  |  2KB  |  86 lines

  1. //========================================================================
  2. //
  3. // OutputDev.cc
  4. //
  5. // Copyright 1996 Derek B. Noonburg
  6. //
  7. //========================================================================
  8.  
  9. #ifdef __GNUC__
  10. #pragma implementation
  11. #endif
  12.  
  13. #include <stddef.h>
  14. #include "Object.h"
  15. #include "Stream.h"
  16. #include "GfxState.h"
  17. #include "OutputDev.h"
  18.  
  19. //------------------------------------------------------------------------
  20. // OutputDev
  21. //------------------------------------------------------------------------
  22.  
  23. void OutputDev::setDefaultCTM(double *ctm1) {
  24.   int i;
  25.   double det;
  26.  
  27.   for (i = 0; i < 6; ++i)
  28.     ctm[i] = ctm1[i];
  29.   det = 1 / (ctm[0] * ctm[3] - ctm[1] * ctm[2]);
  30.   ictm[0] = ctm[3] * det;
  31.   ictm[1] = -ctm[1] * det;
  32.   ictm[2] = -ctm[2] * det;
  33.   ictm[3] = ctm[0] * det;
  34.   ictm[4] = (ctm[2] * ctm[5] - ctm[3] * ctm[4]) * det;
  35.   ictm[5] = (ctm[1] * ctm[4] - ctm[0] * ctm[5]) * det;
  36. }
  37.  
  38. void OutputDev::cvtDevToUser(int dx, int dy, double *ux, double *uy) {
  39.   *ux = ictm[0] * dx + ictm[2] * dy + ictm[4];
  40.   *uy = ictm[1] * dx + ictm[3] * dy + ictm[5];
  41. }
  42.  
  43. void OutputDev::cvtUserToDev(double ux, double uy, int *dx, int *dy) {
  44.   *dx = (int)(ctm[0] * ux + ctm[2] * uy + ctm[4] + 0.5);
  45.   *dy = (int)(ctm[1] * ux + ctm[3] * uy + ctm[5] + 0.5);
  46. }
  47.  
  48. void OutputDev::updateAll(GfxState *state) {
  49.   updateLineDash(state);
  50.   updateFlatness(state);
  51.   updateLineJoin(state);
  52.   updateLineCap(state);
  53.   updateMiterLimit(state);
  54.   updateLineWidth(state);
  55.   updateFillColor(state);
  56.   updateStrokeColor(state);
  57.   updateFont(state);
  58. }
  59.  
  60. void OutputDev::drawImageMask(GfxState *state, Stream *str,
  61.                   int width, int height, GBool invert,
  62.                   GBool inlineImg) {
  63.   int i, j;
  64.  
  65.   if (inlineImg) {
  66.     str->reset();
  67.     j = height * ((width + 7) / 8);
  68.     for (i = 0; i < j; ++i)
  69.       str->getChar();
  70.   }
  71. }
  72.  
  73. void OutputDev::drawImage(GfxState *state, Stream *str, int width,
  74.               int height, GfxImageColorMap *colorMap,
  75.               GBool inlineImg) {
  76.   int i, j;
  77.  
  78.   if (inlineImg) {
  79.     str->reset();
  80.     j = height * ((width * colorMap->getNumPixelComps() *
  81.            colorMap->getBits() + 7) / 8);
  82.     for (i = 0; i < j; ++i)
  83.       str->getChar();
  84.   }
  85. }
  86.