povray/windows/pvbitmap.h
2013-11-06 13:07:19 -05:00

95 lines
4 KiB
C++

/*******************************************************************************
* pvbitmap.h
*
* Provides an API for bitmap manipulation.
*
* This file is derived from Microsoft sample source and is used by permission.
*
* ---------------------------------------------------------------------------
* Persistence of Vision Ray Tracer ('POV-Ray') version 3.7.
* Copyright 1991-2013 Persistence of Vision Raytracer Pty. Ltd.
*
* POV-Ray is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* POV-Ray is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------------
* POV-Ray is based on the popular DKB raytracer version 2.12.
* DKBTrace was originally written by David K. Buck.
* DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
* ---------------------------------------------------------------------------
* $File: //depot/public/povray/3.x/windows/pvbitmap.h $
* $Revision: #1 $
* $Change: 6069 $
* $DateTime: 2013/11/06 11:59:40 $
* $Author: chrisc $
*******************************************************************************/
namespace povwin
{
/* Print Area selection */
#define PW_WINDOW 1
#define PW_CLIENT 2
/* Print Options selection */
#define PW_BESTFIT 1
#define PW_STRETCHTOPAGE 2
#define PW_SCALE 3
/* DIB Macros*/
// WIDTHBYTES performs DWORD-aligning of DIB scanlines. The "bits"
// parameter is the bit count for the scanline (biWidth * biBitCount),
// and this macro returns the number of DWORD-aligned bytes needed
// to hold those bits.
#define WIDTHBYTES(bits) (((bits) + 31) / 32 * 4)
/* Error constants */
enum {
ERR_MIN = 0, // All error #s >= this value
ERR_NOT_DIB = 0, // Tried to load a file, NOT a DIB!
ERR_MEMORY, // Not enough memory!
ERR_READ, // Error reading file!
ERR_LOCK, // Error on a GlobalLock()!
ERR_OPEN, // Error opening a file!
ERR_CREATEPAL, // Error creating palette.
ERR_GETDC, // Couldn't get a DC.
ERR_CREATEDDB, // Error create a DDB.
ERR_STRETCHBLT, // StretchBlt() returned failure.
ERR_STRETCHDIBITS, // StretchDIBits() returned failure.
ERR_SETDIBITSTODEVICE, // SetDIBitsToDevice() failed.
ERR_STARTDOC, // Error calling StartDoc().
ERR_NOGDIMODULE, // Couldn't find GDI module in memory.
ERR_SETABORTPROC, // Error calling SetAbortProc().
ERR_STARTPAGE, // Error calling StartPage().
ERR_NEWFRAME, // Error calling NEWFRAME escape.
ERR_ENDPAGE, // Error calling EndPage().
ERR_ENDDOC, // Error calling EndDoc().
ERR_SETDIBITS, // Error calling SetDIBits().
ERR_FILENOTFOUND, // Error opening file in GetDib()
ERR_INVALIDHANDLE, // Invalid Handle
ERR_DIBFUNCTION, // Error on call to DIB function
ERR_MAX // All error #s < this value
};
/* DIB constants */
#define PALVERSION 0x300
/* DIB macros */
#define IS_WIN30_DIB(lpbi) ((*(LPDWORD)(lpbi)) == sizeof(BITMAPINFOHEADER))
#define RECTWIDTH(lpRect) ((lpRect)->right - (lpRect)->left)
#define RECTHEIGHT(lpRect) ((lpRect)->bottom - (lpRect)->top)
}