2 * DIB driver bitmap objects
4 * Copyright 2009 Massimo Del Fedele
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
22 #include "wine/port.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(dibdrv
);
29 /****************************************************************************
30 * SelectBitmap (WINEDIB.DRV.@)
32 HBITMAP
DIBDRV_SelectBitmap( DIBDRVPHYSDEV
*physDev
, HBITMAP hbitmap
)
34 DIBSECTION dibSection
;
37 MAYBE(TRACE("physDev:%p, hbitmap:%p\n", physDev
, hbitmap
));
39 /* try to get the DIBSECTION data from the bitmap */
40 if(GetObjectW(hbitmap
, sizeof(DIBSECTION
), &dibSection
) != sizeof(DIBSECTION
))
42 /* not a DIB section, sets it on physDev and use X11 behaviour */
44 physDev
->hasDIB
= FALSE
;
45 physDev
->physBitmap
= NULL
;
46 res
= _DIBDRV_GetDisplayDriver()->pSelectBitmap(physDev
->X11PhysDev
, hbitmap
);
48 physDev
->hbitmap
= hbitmap
;
52 /* it's a DIB section, sets it on physDev and use DIB Engine behaviour */
54 /* sets the physical bitmap */
55 if((physDev
->physBitmap
= _BITMAPLIST_Get(hbitmap
)) != NULL
)
57 physDev
->hasDIB
= TRUE
;
58 physDev
->hbitmap
= hbitmap
;
59 MAYBE(TRACE("physDev->physBitmap:%p(%s)\n", physDev
->physBitmap
, _DIBDRVBITMAP_GetFormatName(physDev
->physBitmap
)));
64 ERR("Physical bitmap %p not found in internal list\n", hbitmap
);
65 physDev
->hbitmap
= GetStockObject(DEFAULT_BITMAP
);
66 physDev
->hasDIB
= FALSE
;
73 /****************************************************************************
76 BOOL
DIBDRV_CreateBitmap( DIBDRVPHYSDEV
*physDev
, HBITMAP hbitmap
, LPVOID bmBits
)
78 DIBSECTION dibSection
;
81 MAYBE(TRACE("physDev:%p, hbitmap:%p, bmBits:%p\n", physDev
, hbitmap
, bmBits
));
83 /* try to get the DIBSECTION data from the bitmap */
84 if(GetObjectW(hbitmap
, sizeof(DIBSECTION
), &dibSection
) == sizeof(BITMAP
))
86 /* not a DIB section, use X11 behaviour */
87 res
= _DIBDRV_GetDisplayDriver()->pCreateBitmap(physDev
->X11PhysDev
, hbitmap
, bmBits
);
91 /* it's a DIB section, use DIB Engine behaviour - should not happen, but.... */
92 ERR("CreateBitmap() called for a DIB section - shouldn't happen\n");
98 /***********************************************************************
101 BOOL
DIBDRV_DeleteBitmap( HBITMAP hbitmap
)
103 DIBSECTION dibSection
;
107 MAYBE(TRACE("hbitmap:%p\n", hbitmap
));
109 /* try to get the DIBSECTION data from the bitmap */
110 if(GetObjectW(hbitmap
, sizeof(DIBSECTION
), &dibSection
) != sizeof(DIBSECTION
))
112 /* not a DIB section, use X11 behaviour */
113 res
= _DIBDRV_GetDisplayDriver()->pDeleteBitmap(hbitmap
);
117 /* it's a DIB section, use DIB Engine behaviour */
119 /* do not try to delete stock objects */
120 if(hbitmap
== GetStockObject(DEFAULT_BITMAP
))
123 /* locates and frees the physical bitmap */
124 else if((bmp
= _BITMAPLIST_Remove(hbitmap
)) != NULL
)
126 _DIBDRVBITMAP_Free(bmp
);
131 ERR("Physical bitmap %p not found in internal list\n", hbitmap
);
138 /***********************************************************************
139 * DIBDRV_GetBitmapBits
141 LONG
DIBDRV_GetBitmapBits( HBITMAP hbitmap
, void *buffer
, LONG count
)
145 MAYBE(TRACE("hbitmap:%p, buffer:%p, count:%d\n", hbitmap
, buffer
, count
));
147 /* GetBitmapBits is only valid for DDBs, so use X11 driver */
148 res
= _DIBDRV_GetDisplayDriver()->pGetBitmapBits(hbitmap
, buffer
, count
);
153 /******************************************************************************
154 * DIBDRV_SetBitmapBits
156 LONG
DIBDRV_SetBitmapBits( HBITMAP hbitmap
, const void *bits
, LONG count
)
160 MAYBE(TRACE("hbitmap:%p, bits:%p, count:%d\n", hbitmap
, bits
, count
));
162 /* SetBitmapBits is only valid for DDBs, so use X11 driver */
163 res
= _DIBDRV_GetDisplayDriver()->pSetBitmapBits(hbitmap
, bits
, count
);