dibdrv: Check for top-down DIBs
[wine/dibdrv.git] / dlls / winedib.drv / dibdrv.h
blob06d3e5e6188aebcf3b4beedebe2ea370c3223cbd
1 /*
2 * DIB driver private definitions
4 * Copyright 2007 Jesse Allen
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef __WINE_DIBDRV_H
22 #define __WINE_DIBDRV_H
24 #include "wingdi.h"
26 typedef enum _DIBFORMAT
28 DIBFMT_UNKNOWN = 0,
29 DIBFMT_DIB1 = 1,
30 DIBFMT_DIB4 = 2,
31 /*DIBFMT_DIB4RLE = 3,*/
32 DIBFMT_DIB8 = 4,
33 /*DIBFMT_DIB8RLE = 5,*/
34 DIBFMT_DIB16 = 6,
35 DIBFMT_DIB24 = 7,
36 DIBFMT_DIB32 = 8,
37 DIBFMT_X1B5G5R5 = 9,
38 DIBFMT_X8B8G8R8 = 10
39 } DIBFORMAT;
41 /* DIB driver's generic bitmap structure */
42 typedef struct _DIBDRVBITMAP
44 DIBFORMAT format;
45 void *bits;
46 INT width;
47 INT height;
48 INT widthbytes;
49 INT size;
50 BOOL top_down;
51 RGBQUAD *color_table;
52 UINT nb_colors;
53 DWORD bitfields[3];
55 /* calculated numbers for bitfields */
56 INT bf_pos[3]; /* starting position of the field */
57 INT bf_size[3]; /* size of the field */
58 INT bf_shift[3]; /* shifting required within a COLORREF's BYTE */
60 /* current drawing address */
61 void *addr;
62 INT shift;
64 /* ready encoded colors for drawing */
65 BYTE color8;
66 WORD color16;
67 RGBTRIPLE color24;
68 DWORD color32;
69 } DIBDRVBITMAP;
71 /* DIB conversions functions */
72 typedef struct _DIBCONVERT
74 void (*ConvertToDIB1)(DIBDRVBITMAP*,DIBDRVBITMAP*,int);
75 void (*ConvertToDIB4)(DIBDRVBITMAP*,DIBDRVBITMAP*,int);
76 void (*ConvertToDIB8)(DIBDRVBITMAP*,DIBDRVBITMAP*,int);
77 void (*ConvertToDIB16)(DIBDRVBITMAP*,DIBDRVBITMAP*,int);
78 void (*ConvertToDIB24)(DIBDRVBITMAP*,DIBDRVBITMAP*,int);
79 void (*ConvertToDIB32)(DIBDRVBITMAP*,DIBDRVBITMAP*,int);
80 } DIBCONVERT;
82 /* DIB manipulation functions */
83 typedef struct _DIBFUNCS
85 void (*AdvancePosition)(DIBDRVBITMAP*,int);
86 void (*Copy)(DIBDRVBITMAP*,DIBDRVBITMAP*,int,const DIBCONVERT*);
87 void (*MoveXY)(DIBDRVBITMAP*,INT,INT);
88 void (*ReadColor)(DIBDRVBITMAP*,BYTE*,BYTE*,BYTE*);
89 void (*SelectColor)(DIBDRVBITMAP*,COLORREF);
90 void (*SetPixel)(DIBDRVBITMAP*,COLORREF);
91 void (*WriteColor)(DIBDRVBITMAP*,int);
92 } DIBFUNCS;
94 /* DIB driver physical device */
95 typedef struct _DIBDRVPHYSDEV
97 HDC hdc;
98 HBITMAP hbitmap;
99 DIBDRVBITMAP *bmp;
100 const DIBFUNCS *funcs;
101 const DIBCONVERT *convs;
102 } DIBDRVPHYSDEV;
104 /* bitmap handling functions */
105 extern DIBFORMAT BITMAP_GetFormat( WORD depth, DWORD compression );
106 extern const DIBFUNCS *BITMAP_GetDIBFuncs( DIBFORMAT format );
107 extern const DIBCONVERT *BITMAP_GetDIBConversions( DIBFORMAT format );
108 extern DIBDRVBITMAP *BITMAP_CreateFromBmi( const BITMAPINFO *bmi, void *bits );
109 extern DIBDRVBITMAP *BITMAP_CreateFromHBitmap( HBITMAP hbitmap, RGBQUAD *ct, UINT nb_colors );
111 /* DIB function tables for each format */
112 extern const DIBFUNCS DIB1_funcs, DIB4_funcs, DIB8_funcs, DIB16_funcs, DIB24_funcs, DIB32_funcs;
113 extern const DIBCONVERT DIB1_convs, DIB4_convs, DIB8_convs, DIB16_convs, DIB24_convs, DIB32_convs;
115 #endif /* __WINE_DIBDRV_H */