DIBAPI.H 6.5 KB

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