2 * DIBDRV device-independent bitmaps
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
26 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(dibdrv
);
32 /***********************************************************************
33 * DIBDRV_CreateDIBSection
35 HBITMAP
DIBDRV_CreateDIBSection( DIBDRVPHYSDEV
*physDev
, HBITMAP hbitmap
,
36 const BITMAPINFO
*bmi
, UINT usage
)
42 /***********************************************************************
45 INT
DIBDRV_GetDIBits( DIBDRVPHYSDEV
*physDev
, HBITMAP hbitmap
, UINT startscan
,
46 UINT lines
, LPCVOID bits
, const BITMAPINFO
*info
, UINT coloruse
)
48 const DIBFUNCS
*dst_funcs
, *src_funcs
;
49 const DIBCONVERT
*convs
;
50 DIBDRVBITMAP
*dst
, *src
;
53 TRACE("%p %p %u %u %p %p %u\n", physDev
, hbitmap
, startscan
, lines
, bits
, info
, coloruse
);
55 dst
= BITMAP_CreateFromBmi( info
, (void *)bits
);
58 src
= BITMAP_CreateFromHBitmap( hbitmap
, physDev
->bmp
->color_table
, physDev
->bmp
->nb_colors
);
61 HeapFree( GetProcessHeap(), 0, dst
);
65 convs
= BITMAP_GetDIBConversions( src
->format
);
66 dst_funcs
= BITMAP_GetDIBFuncs( dst
->format
);
67 src_funcs
= BITMAP_GetDIBFuncs( src
->format
);
68 min_width
= src
->width
< dst
->width
? src
->width
: dst
->width
;
70 /* copy a scanline at a time */
71 for (i
= startscan
; i
< startscan
+ lines
; i
++)
73 dst_funcs
->MoveXY( dst
, 0, i
);
74 src_funcs
->MoveXY( src
, 0, i
);
75 dst_funcs
->Copy( dst
, src
, min_width
, convs
);
78 HeapFree( GetProcessHeap(), 0, dst
);
79 HeapFree( GetProcessHeap(), 0, src
);
83 /***********************************************************************
84 * DIBDRV_SetDIBColorTable
86 UINT
DIBDRV_SetDIBColorTable( DIBDRVPHYSDEV
*physDev
, UINT start
, UINT count
,
87 const RGBQUAD
*colors
)
89 TRACE("%p %u %u %p\n", physDev
, start
, count
, colors
);
90 if (!physDev
->bmp
->color_table
|| start
+ count
> physDev
->bmp
->nb_colors
)
92 memcpy(physDev
->bmp
->color_table
+ start
*sizeof(RGBQUAD
), colors
, count
*sizeof(RGBQUAD
));
96 /***********************************************************************
99 INT
DIBDRV_SetDIBits( DIBDRVPHYSDEV
*physDev
, HBITMAP hbitmap
, UINT startscan
,
100 UINT lines
, LPCVOID bits
, const BITMAPINFO
*info
, UINT coloruse
)
102 const DIBFUNCS
*dst_funcs
, *src_funcs
;
103 const DIBCONVERT
*convs
;
104 DIBDRVBITMAP
*dst
, *src
;
107 TRACE("%p %p %u %u %p %p %u\n", physDev
, hbitmap
, startscan
, lines
, bits
, info
, coloruse
);
109 dst
= BITMAP_CreateFromHBitmap( hbitmap
, physDev
->bmp
->color_table
, physDev
->bmp
->nb_colors
);
112 src
= BITMAP_CreateFromBmi( info
, (void *)bits
);
115 HeapFree( GetProcessHeap(), 0, dst
);
119 convs
= BITMAP_GetDIBConversions( src
->format
);
120 dst_funcs
= BITMAP_GetDIBFuncs( dst
->format
);
121 src_funcs
= BITMAP_GetDIBFuncs( src
->format
);
122 min_width
= dst
->width
< src
->width
? dst
->width
: src
->width
;
124 /* copy a scanline at a time */
125 for (i
= startscan
; i
< startscan
+ lines
; i
++)
127 dst_funcs
->MoveXY( dst
, 0, i
);
128 src_funcs
->MoveXY( src
, 0, i
);
129 dst_funcs
->Copy( dst
, src
, min_width
, convs
);
132 HeapFree( GetProcessHeap(), 0, dst
);
133 HeapFree( GetProcessHeap(), 0, src
);
134 return i
- startscan
;
137 /*************************************************************************
138 * DIBDRV_SetDIBitsToDevice
140 INT
DIBDRV_SetDIBitsToDevice( DIBDRVPHYSDEV
*physDev
, INT xDest
, INT yDest
, DWORD cx
,
141 DWORD cy
, INT xSrc
, INT ySrc
,
142 UINT startscan
, UINT lines
, LPCVOID bits
,
143 const BITMAPINFO
*info
, UINT coloruse
)
145 const DIBFUNCS
*src_funcs
;
146 const DIBCONVERT
*convs
;
150 FIXME("not finished: %p %d %d %u %u %d %d %u %u %p %p %u\n", physDev
, xDest
, yDest
, cx
, cy
,
151 xSrc
, ySrc
, startscan
, lines
, bits
, info
, coloruse
);
153 src
= BITMAP_CreateFromBmi( info
, (void *)bits
);
156 convs
= BITMAP_GetDIBConversions( src
->format
);
157 src_funcs
= BITMAP_GetDIBFuncs( src
->format
);
158 min_width
= physDev
->bmp
->width
< src
->width
? physDev
->bmp
->width
: src
->width
;
160 /* copy a scanline at a time */
161 for (i
= startscan
; i
< startscan
+ lines
; i
++)
163 physDev
->funcs
->MoveXY( physDev
->bmp
, xDest
, yDest
+ i
);
164 src_funcs
->MoveXY( src
, xSrc
, ySrc
+ i
);
165 physDev
->funcs
->Copy( physDev
->bmp
, src
, min_width
, physDev
->convs
);
168 HeapFree( GetProcessHeap(), 0, src
);
169 return i
- startscan
;