DIBAPI.H (6656B)
1 // 2 // Copyright 2020 Electronic Arts Inc. 3 // 4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 5 // software: you can redistribute it and/or modify it under the terms of 6 // the GNU General Public License as published by the Free Software Foundation, 7 // either version 3 of the License, or (at your option) any later version. 8 9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 10 // in the hope that it will be useful, but with permitted additional restrictions 11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 // distributed with this program. You should have received a copy of the 13 // GNU General Public License along with permitted additional restrictions 14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection 15 16 #ifndef DIBAPI_H 17 #define DIBAPI_H 18 /* 19 * dibapi.h 20 * 21 * Copyright (c) 1991 Microsoft Corporation. All rights reserved 22 * 23 * Header file for Device-Independent Bitmap (DIB) API. Provides 24 * function prototypes and constants for the following functions: 25 * 26 * BitmapToDIB() - Creates a DIB from a bitmap 27 * ChangeBitmapFormat() - Changes a bitmap to a specified DIB format 28 * ChangeDIBFormat() - Changes a DIB's BPP and/or compression format 29 * CopyScreenToBitmap() - Copies entire screen to a standard Bitmap 30 * CopyScreenToDIB() - Copies entire screen to a DIB 31 * CopyWindowToBitmap() - Copies a window to a standard Bitmap 32 * CopyWindowToDIB() - Copies a window to a DIB 33 * CreateDIBPalette() - Creates a palette from a DIB 34 * CreateDIB() - Creates a new DIB 35 * DestroyDIB() - Deletes DIB when finished using it 36 * DIBError() - Displays message box with error message 37 * DIBHeight() - Gets the DIB height 38 * DIBNumColors() - Calculates number of colors in the DIB's color table 39 * DIBToBitmap() - Creates a bitmap from a DIB 40 * DIBWidth() - Gets the DIB width 41 * FindDIBBits() - Sets pointer to the DIB bits 42 * GetSystemPalette() - Gets the current palette 43 * LoadDIB() - Loads a DIB from a file 44 * PaintBitmap() - Displays standard bitmap in the specified DC 45 * PaintDIB() - Displays DIB in the specified DC 46 * PalEntriesOnDevice() - Gets the number of palette entries 47 * PaletteSize() - Calculates the buffer size required by a palette 48 * PrintDIB() - Prints the specified DIB 49 * PrintScreen() - Prints the entire screen 50 * PrintWindow() - Prints all or part of a window 51 * SaveDIB() - Saves the specified dib in a file 52 * 53 * See the file DIBAPI.TXT for more information about these functions. 54 * 55 * ajw added 56 * LoadDIB_FromMemory() - Loads a DIB from BMP file data located at a location in memory. 57 * 58 */ 59 60 61 /* Handle to a DIB */ 62 #define HDIB HANDLE 63 64 65 /* Print Area selection */ 66 #define PW_WINDOW 1 67 #define PW_CLIENT 2 68 69 70 /* Print Options selection */ 71 #define PW_BESTFIT 1 72 #define PW_STRETCHTOPAGE 2 73 #define PW_SCALE 3 74 75 /* DIB Macros*/ 76 77 // WIDTHBYTES performs DWORD-aligning of DIB scanlines. The "bits" 78 // parameter is the bit count for the scanline (biWidth * biBitCount), 79 // and this macro returns the number of DWORD-aligned bytes needed 80 // to hold those bits. 81 82 #define WIDTHBYTES(bits) (((bits) + 31) / 32 * 4) 83 84 /* Error constants */ 85 enum { 86 ERR_MIN = 0, // All error #s >= this value 87 ERR_NOT_DIB = 0, // Tried to load a file, NOT a DIB! 88 ERR_MEMORY, // Not enough memory! 89 ERR_READ, // Error reading file! 90 ERR_LOCK, // Error on a GlobalLock()! 91 ERR_OPEN, // Error opening a file! 92 ERR_CREATEPAL, // Error creating palette. 93 ERR_GETDC, // Couldn't get a DC. 94 ERR_CREATEDDB, // Error create a DDB. 95 ERR_STRETCHBLT, // StretchBlt() returned failure. 96 ERR_STRETCHDIBITS, // StretchDIBits() returned failure. 97 ERR_SETDIBITSTODEVICE, // SetDIBitsToDevice() failed. 98 ERR_STARTDOC, // Error calling StartDoc(). 99 ERR_NOGDIMODULE, // Couldn't find GDI module in memory. 100 ERR_SETABORTPROC, // Error calling SetAbortProc(). 101 ERR_STARTPAGE, // Error calling StartPage(). 102 ERR_NEWFRAME, // Error calling NEWFRAME escape. 103 ERR_ENDPAGE, // Error calling EndPage(). 104 ERR_ENDDOC, // Error calling EndDoc(). 105 ERR_SETDIBITS, // Error calling SetDIBits(). 106 ERR_FILENOTFOUND, // Error opening file in GetDib() 107 ERR_INVALIDHANDLE, // Invalid Handle 108 ERR_DIBFUNCTION, // Error on call to DIB function 109 ERR_MAX // All error #s < this value 110 }; 111 112 113 114 /* Function prototypes */ 115 116 HDIB FAR BitmapToDIB (HBITMAP hBitmap, HPALETTE hPal); 117 HDIB FAR ChangeBitmapFormat (HBITMAP hBitmap, 118 WORD wBitCount, 119 DWORD dwCompression, 120 HPALETTE hPal); 121 HDIB FAR ChangeDIBFormat (HDIB hDIB, WORD wBitCount, 122 DWORD dwCompression); 123 HBITMAP FAR CopyScreenToBitmap (LPRECT); 124 HDIB FAR CopyScreenToDIB (LPRECT); 125 HBITMAP FAR CopyWindowToBitmap (HWND, WORD); 126 HDIB FAR CopyWindowToDIB (HWND, WORD); 127 HPALETTE FAR CreateDIBPalette (HDIB hDIB); 128 HDIB FAR CreateDIB(DWORD, DWORD, WORD); 129 WORD FAR DestroyDIB (HDIB); 130 void FAR DIBError (int ErrNo); 131 DWORD FAR DIBHeight (LPCSTR lpDIB); 132 WORD FAR DIBNumColors (LPCSTR lpDIB); 133 HBITMAP FAR DIBToBitmap (HDIB hDIB, HPALETTE hPal); 134 DWORD FAR DIBWidth (LPCSTR lpDIB); 135 LPSTR FAR FindDIBBits (LPCSTR lpDIB); 136 HPALETTE FAR GetSystemPalette (void); 137 HDIB FAR LoadDIB (LPSTR); 138 BOOL FAR PaintBitmap (HDC, LPRECT, HBITMAP, LPRECT, HPALETTE); 139 BOOL FAR PaintDIB (HDC, LPRECT, HDIB, LPRECT, HPALETTE); 140 int FAR PalEntriesOnDevice (HDC hDC); 141 WORD FAR PaletteSize (LPCSTR lpDIB); 142 WORD FAR PrintDIB (HDIB, WORD, WORD, WORD, LPSTR); 143 WORD FAR PrintScreen (LPRECT, WORD, WORD, WORD, LPSTR); 144 WORD FAR PrintWindow (HWND, WORD, WORD, WORD, WORD, LPSTR); 145 WORD FAR SaveDIB (HDIB, LPSTR); 146 147 // ajw added 148 HDIB LoadDIB_FromMemory( const unsigned char* pData, DWORD dwBitsSize ); 149 150 #endif