DIBAPI.H 6.4 KB

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