/ windows / pvbitmap.h
pvbitmap.h
 1  /*******************************************************************************
 2   * pvbitmap.h
 3   *
 4   * Provides an API for bitmap manipulation.
 5   *
 6   * This file is derived from Microsoft sample source and is used by permission.
 7   *
 8   * ---------------------------------------------------------------------------
 9   * Persistence of Vision Ray Tracer ('POV-Ray') version 3.7.
10   * Copyright 1991-2013 Persistence of Vision Raytracer Pty. Ltd.
11   *
12   * POV-Ray is free software: you can redistribute it and/or modify
13   * it under the terms of the GNU Affero General Public License as
14   * published by the Free Software Foundation, either version 3 of the
15   * License, or (at your option) any later version.
16   *
17   * POV-Ray is distributed in the hope that it will be useful,
18   * but WITHOUT ANY WARRANTY; without even the implied warranty of
19   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20   * GNU Affero General Public License for more details.
21   *
22   * You should have received a copy of the GNU Affero General Public License
23   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
24   * ---------------------------------------------------------------------------
25   * POV-Ray is based on the popular DKB raytracer version 2.12.
26   * DKBTrace was originally written by David K. Buck.
27   * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
28   * ---------------------------------------------------------------------------
29   * $File: //depot/public/povray/3.x/windows/pvbitmap.h $
30   * $Revision: #1 $
31   * $Change: 6069 $
32   * $DateTime: 2013/11/06 11:59:40 $
33   * $Author: chrisc $
34   *******************************************************************************/
35  
36  namespace povwin
37  {
38  
39  /* Print Area selection */
40  #define PW_WINDOW        1
41  #define PW_CLIENT        2
42  
43  /* Print Options selection */
44  #define PW_BESTFIT       1
45  #define PW_STRETCHTOPAGE 2
46  #define PW_SCALE         3
47  
48  /* DIB Macros*/
49  
50  // WIDTHBYTES performs DWORD-aligning of DIB scanlines.  The "bits"
51  // parameter is the bit count for the scanline (biWidth * biBitCount),
52  // and this macro returns the number of DWORD-aligned bytes needed
53  // to hold those bits.
54  
55  #define WIDTHBYTES(bits)    (((bits) + 31) / 32 * 4)
56  
57  /* Error constants */
58  enum {
59        ERR_MIN = 0,                     // All error #s >= this value
60        ERR_NOT_DIB = 0,                 // Tried to load a file, NOT a DIB!
61        ERR_MEMORY,                      // Not enough memory!
62        ERR_READ,                        // Error reading file!
63        ERR_LOCK,                        // Error on a GlobalLock()!
64        ERR_OPEN,                        // Error opening a file!
65        ERR_CREATEPAL,                   // Error creating palette.
66        ERR_GETDC,                       // Couldn't get a DC.
67        ERR_CREATEDDB,                   // Error create a DDB.
68        ERR_STRETCHBLT,                  // StretchBlt() returned failure.
69        ERR_STRETCHDIBITS,               // StretchDIBits() returned failure.
70        ERR_SETDIBITSTODEVICE,           // SetDIBitsToDevice() failed.
71        ERR_STARTDOC,                    // Error calling StartDoc().
72        ERR_NOGDIMODULE,                 // Couldn't find GDI module in memory.
73        ERR_SETABORTPROC,                // Error calling SetAbortProc().
74        ERR_STARTPAGE,                   // Error calling StartPage().
75        ERR_NEWFRAME,                    // Error calling NEWFRAME escape.
76        ERR_ENDPAGE,                     // Error calling EndPage().
77        ERR_ENDDOC,                      // Error calling EndDoc().
78        ERR_SETDIBITS,                   // Error calling SetDIBits().
79        ERR_FILENOTFOUND,                // Error opening file in GetDib()
80        ERR_INVALIDHANDLE,               // Invalid Handle
81        ERR_DIBFUNCTION,                 // Error on call to DIB function
82        ERR_MAX                          // All error #s < this value
83       };
84  
85  
86  
87  /* DIB constants */
88  #define PALVERSION   0x300
89  
90  /* DIB macros */
91  #define IS_WIN30_DIB(lpbi)  ((*(LPDWORD)(lpbi)) == sizeof(BITMAPINFOHEADER))
92  #define RECTWIDTH(lpRect)     ((lpRect)->right - (lpRect)->left)
93  #define RECTHEIGHT(lpRect)    ((lpRect)->bottom - (lpRect)->top)
94  
95  }