win32dib.h
上传用户:shenzhenrh
上传日期:2013-05-12
资源大小:2904k
文件大小:3k
源码类别:

信息检索与抽取

开发平台:

Unix_Linux

  1. #ifndef _DIB_H
  2. #define _DIB_H
  3. #ifdef __CYGWIN__
  4. #define _WIN32
  5. #endif
  6. #ifdef _WIN32
  7. #include <windows.h>
  8. #include <windowsx.h>
  9. #define BOOL OBJC_BOOL
  10. #include <misc.h>
  11. #undef BOOL
  12. /* 1 = Top-Down   0 = Bottom-Up */
  13. #define TOP_DOWN_DIB 1
  14. /* BITMAPINFO */
  15. typedef struct CDIB_BITMAP {
  16.   BITMAPINFOHEADER bmiHead;
  17.   RGBQUAD rgb[256]; // Not used for BI_RGB with more than 256 colors.
  18. } CDIB_BITMAP;
  19. typedef struct dib {
  20.   /* Controlling window */
  21.   HWND window;
  22.   HDC sourceDC;
  23.   HDC destDC;
  24.   CDIB_BITMAP *dibInfo;
  25.   
  26.   /* Bitmap */
  27.   HBITMAP bitmap;
  28.   HBITMAP oldBitmap;
  29.   void /* far */ *bits;
  30.   unsigned colormapOffsets[256];
  31.   void *colormapObjects[256];
  32.   unsigned colormapBlocks;
  33.   unsigned colormapSize;
  34.   unsigned long *colormap; // only used for when depth > 8
  35.   /* Palette */
  36.   HPALETTE *palette;
  37.   HPALETTE *oldPalette;
  38.   /* Offset coordinates */
  39.   int xBitmapOffset;
  40.   int yBitmapOffset;
  41. } dib_t;
  42. /* Constructor */
  43. dib_t *dib_create (void);
  44. void dib_destroy (dib_t *dib);
  45. void dib_createBitmap (dib_t *dib, HWND window, unsigned width, unsigned height);
  46. void dib_deleteBitmap (dib_t *dib);
  47. /* Palette Manipulation */
  48. int dib_paletteIndexForObject (dib_t *dib, void *object);
  49. void dib_get_color (dib_t *dib, void *object, unsigned color, BYTE *red, BYTE *green, BYTE *blue);
  50. void dib_augmentPalette (dib_t *dib, void *object,
  51.  unsigned mapSize, unsigned long *map);
  52. /* Called from a WM_PAINT command -- No locking required. */
  53. BOOL dib_paintBlit (dib_t *dib,
  54.     HDC destHdc,
  55.     int destX, int destY,
  56.     int sourceX, int sourceY,
  57.     unsigned sourceWidth, unsigned sourceHeight);
  58. void dib_fill (dib_t *dib, int x, int y, unsigned width, unsigned height, void *object, unsigned color);
  59. void dib_ellipse (dib_t *dib, int x, int y, unsigned width, unsigned height, unsigned pixels, void *object, unsigned color);
  60. void dib_line (dib_t *dib, int x0, int y0, int x1, int y1, unsigned pixels, void *object, unsigned color);
  61. void dib_rectangle (dib_t *dib, int x, int y, unsigned width, unsigned height, unsigned pixels, void *object, unsigned color);
  62. BOOL dib_copy (dib_t *source, dib_t *dest, int destx, int desty, unsigned width, unsigned height);
  63. void dib_copy_metadata (dib_t *source, dib_t *dest);
  64. LPBYTE dib_lock (dib_t *dib);
  65. void dib_unlock (dib_t *dib);
  66. void dib_snapshot(dib_t *dib, BOOL windowDCFlag);
  67. #if 0
  68. /* Used to control what part of the bitmap gets shown to the screen */
  69. /* Helps with scrolling / oversized senarios */
  70. void dib_setPaintOffset (dib_t *dib, int xOffset, int yOffset);
  71. /* Surface info */
  72. LPBYTE dib_getSurface (dib_t *dib);
  73. int dib_getWidth (dib_t *dib);
  74. int dib_getHeight (dib_t *dib);
  75. /* Blitting interface  */
  76. /* Make sure to: 1) Lock surface, 2) Blit, 3) Unlock surface */
  77. BOOL dib_blit (dib_t *dib,
  78.        int destX, int destY,
  79.        int sourceX, int sourceY,
  80.        unsigned sourceWidth, unsigned sourceHeight);
  81. #endif
  82. #endif
  83. #endif