Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
f7ffbe45
Commit
f7ffbe45
authored
Nov 08, 2006
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdi32: Remove call to CreateCompatibleDC() from GetDIBits() implementation.
Based on a patch by Alex Villacís Lasso.
parent
68817c10
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
120 additions
and
32 deletions
+120
-32
bitmap.c
dlls/gdi32/bitmap.c
+3
-0
dib.c
dlls/gdi32/dib.c
+114
-28
gdi_private.h
dlls/gdi32/gdi_private.h
+2
-0
bitmap.c
dlls/gdi32/tests/bitmap.c
+1
-4
No files found.
dlls/gdi32/bitmap.c
View file @
f7ffbe45
...
...
@@ -279,6 +279,8 @@ HBITMAP WINAPI CreateBitmapIndirect( const BITMAP *bmp )
bmpobj
->
funcs
=
NULL
;
bmpobj
->
dib
=
NULL
;
bmpobj
->
segptr_bits
=
0
;
bmpobj
->
color_table
=
NULL
;
bmpobj
->
nb_colors
=
0
;
if
(
bm
.
bmBits
)
SetBitmapBits
(
hbitmap
,
bm
.
bmHeight
*
bm
.
bmWidthBytes
,
bm
.
bmBits
);
...
...
@@ -628,6 +630,7 @@ static BOOL BITMAP_DeleteObject( HGDIOBJ handle, void *obj )
for
(
i
=
0
;
i
<
count
;
i
++
)
FreeSelector16
(
sel
+
(
i
<<
__AHSHIFT
));
}
HeapFree
(
GetProcessHeap
(),
0
,
bmp
->
color_table
);
}
return
GDI_FreeObject
(
handle
,
obj
);
}
...
...
dlls/gdi32/dib.c
View file @
f7ffbe45
...
...
@@ -387,11 +387,27 @@ UINT WINAPI SetDIBColorTable( HDC hdc, UINT startpos, UINT entries, CONST RGBQUA
{
DC
*
dc
;
UINT
result
=
0
;
BITMAPOBJ
*
bitmap
;
if
(
!
(
dc
=
DC_GetDCUpdate
(
hdc
)))
return
0
;
if
(
!
(
dc
=
DC_GetDCPtr
(
hdc
)))
return
0
;
if
((
bitmap
=
GDI_GetObjPtr
(
dc
->
hBitmap
,
BITMAP_MAGIC
)))
{
/* Check if currently selected bitmap is a DIB */
if
(
bitmap
->
color_table
)
{
if
(
startpos
<
bitmap
->
nb_colors
)
{
if
(
startpos
+
entries
>
bitmap
->
nb_colors
)
entries
=
bitmap
->
nb_colors
-
startpos
;
memcpy
(
bitmap
->
color_table
+
startpos
,
colors
,
entries
*
sizeof
(
RGBQUAD
));
result
=
entries
;
}
}
GDI_ReleaseObj
(
dc
->
hBitmap
);
}
if
(
dc
->
funcs
->
pSetDIBColorTable
)
result
=
dc
->
funcs
->
pSetDIBColorTable
(
dc
->
physDev
,
startpos
,
entries
,
colors
);
dc
->
funcs
->
pSetDIBColorTable
(
dc
->
physDev
,
startpos
,
entries
,
colors
);
GDI_ReleaseObj
(
hdc
);
return
result
;
...
...
@@ -406,11 +422,28 @@ UINT WINAPI GetDIBColorTable( HDC hdc, UINT startpos, UINT entries, RGBQUAD *col
DC
*
dc
;
UINT
result
=
0
;
if
(
!
(
dc
=
DC_GetDC
Update
(
hdc
)))
return
0
;
if
(
!
(
dc
=
DC_GetDC
Ptr
(
hdc
)))
return
0
;
if
(
dc
->
funcs
->
pGetDIBColorTable
)
result
=
dc
->
funcs
->
pGetDIBColorTable
(
dc
->
physDev
,
startpos
,
entries
,
colors
);
else
{
BITMAPOBJ
*
bitmap
=
GDI_GetObjPtr
(
dc
->
hBitmap
,
BITMAP_MAGIC
);
if
(
bitmap
)
{
/* Check if currently selected bitmap is a DIB */
if
(
bitmap
->
color_table
)
{
if
(
startpos
<
bitmap
->
nb_colors
)
{
if
(
startpos
+
entries
>
bitmap
->
nb_colors
)
entries
=
bitmap
->
nb_colors
-
startpos
;
memcpy
(
colors
,
bitmap
->
color_table
+
startpos
,
entries
*
sizeof
(
RGBQUAD
));
result
=
entries
;
}
}
GDI_ReleaseObj
(
dc
->
hBitmap
);
}
}
GDI_ReleaseObj
(
hdc
);
return
result
;
}
...
...
@@ -533,7 +566,6 @@ INT WINAPI GetDIBits(
DC
*
dc
;
BITMAPOBJ
*
bmp
;
int
i
;
HDC
memdc
;
int
bitmap_type
;
BOOL
core_header
;
LONG
width
;
...
...
@@ -553,16 +585,13 @@ INT WINAPI GetDIBits(
return
0
;
}
core_header
=
(
bitmap_type
==
0
);
memdc
=
CreateCompatibleDC
(
hdc
);
if
(
!
(
dc
=
DC_GetDCUpdate
(
hdc
)))
{
DeleteDC
(
memdc
);
return
0
;
}
if
(
!
(
bmp
=
(
BITMAPOBJ
*
)
GDI_GetObjPtr
(
hbitmap
,
BITMAP_MAGIC
)))
{
GDI_ReleaseObj
(
hdc
);
DeleteDC
(
memdc
);
return
0
;
}
...
...
@@ -580,34 +609,25 @@ INT WINAPI GetDIBits(
same color depth then get the color map from it */
if
(
bmp
->
dib
&&
bmp
->
dib
->
dsBm
.
bmBitsPixel
==
bpp
)
{
if
(
coloruse
==
DIB_RGB_COLORS
)
{
HBITMAP
oldbm
=
SelectObject
(
memdc
,
hbitmap
);
unsigned
int
colors
=
1
<<
bpp
;
unsigned
int
colors
=
min
(
bmp
->
nb_colors
,
1
<<
bpp
);
if
(
core_header
)
{
/* Convert the color table (RGBQUAD to RGBTRIPLE) */
RGB
QUAD
*
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
colors
*
sizeof
(
RGBQUAD
))
;
/* Convert the color table (RGBQUAD to RGBTRIPLE) */
RGB
TRIPLE
*
index
=
rgbTriples
;
if
(
buffer
)
for
(
i
=
0
;
i
<
colors
;
i
++
,
index
++
)
{
RGBTRIPLE
*
index
=
rgbTriples
;
GetDIBColorTable
(
memdc
,
0
,
colors
,
buffer
);
for
(
i
=
0
;
i
<
colors
;
i
++
,
index
++
)
{
index
->
rgbtRed
=
buffer
[
i
].
rgbRed
;
index
->
rgbtGreen
=
buffer
[
i
].
rgbGreen
;
index
->
rgbtBlue
=
buffer
[
i
].
rgbBlue
;
}
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
index
->
rgbtRed
=
bmp
->
color_table
[
i
].
rgbRed
;
index
->
rgbtGreen
=
bmp
->
color_table
[
i
].
rgbGreen
;
index
->
rgbtBlue
=
bmp
->
color_table
[
i
].
rgbBlue
;
}
}
else
{
GetDIBColorTable
(
memdc
,
0
,
colors
,
colorPtr
);
if
(
colors
!=
1
<<
bpp
)
info
->
bmiHeader
.
biClrUsed
=
colors
;
memcpy
(
colorPtr
,
bmp
->
color_table
,
colors
*
sizeof
(
RGBQUAD
));
}
SelectObject
(
memdc
,
oldbm
);
}
else
{
WORD
*
index
=
colorPtr
;
...
...
@@ -623,7 +643,6 @@ INT WINAPI GetDIBits(
if
(
!
(
palette
=
(
PALETTEOBJ
*
)
GDI_GetObjPtr
(
dc
->
hPalette
,
PALETTE_MAGIC
)))
{
GDI_ReleaseObj
(
hdc
);
GDI_ReleaseObj
(
hbitmap
);
DeleteDC
(
memdc
);
return
0
;
}
palEntry
=
palette
->
logpalette
.
palPalEntry
;
...
...
@@ -1019,7 +1038,6 @@ INT WINAPI GetDIBits(
GDI_ReleaseObj
(
hdc
);
GDI_ReleaseObj
(
hbitmap
);
DeleteDC
(
memdc
);
return
lines
;
}
...
...
@@ -1126,6 +1144,72 @@ HBITMAP16 WINAPI CreateDIBSection16 (HDC16 hdc, const BITMAPINFO *bmi, UINT16 us
return
HBITMAP_16
(
hbitmap
);
}
/* Copy/synthetize RGB palette from BITMAPINFO. Ripped from dlls/winex11.drv/dib.c */
static
void
DIB_CopyColorTable
(
DC
*
dc
,
BITMAPOBJ
*
bmp
,
WORD
coloruse
,
const
BITMAPINFO
*
info
)
{
RGBQUAD
*
colorTable
;
unsigned
int
colors
;
int
i
;
BOOL
core_info
=
info
->
bmiHeader
.
biSize
==
sizeof
(
BITMAPCOREHEADER
);
if
(
core_info
)
{
colors
=
1
<<
((
const
BITMAPCOREINFO
*
)
info
)
->
bmciHeader
.
bcBitCount
;
}
else
{
colors
=
info
->
bmiHeader
.
biClrUsed
;
if
(
!
colors
)
colors
=
1
<<
info
->
bmiHeader
.
biBitCount
;
}
if
(
colors
>
256
)
{
ERR
(
"called with >256 colors!
\n
"
);
return
;
}
if
(
!
(
colorTable
=
HeapAlloc
(
GetProcessHeap
(),
0
,
colors
*
sizeof
(
RGBQUAD
)
)))
return
;
if
(
coloruse
==
DIB_RGB_COLORS
)
{
if
(
core_info
)
{
/* Convert RGBTRIPLEs to RGBQUADs */
for
(
i
=
0
;
i
<
colors
;
i
++
)
{
colorTable
[
i
].
rgbRed
=
((
const
BITMAPCOREINFO
*
)
info
)
->
bmciColors
[
i
].
rgbtRed
;
colorTable
[
i
].
rgbGreen
=
((
const
BITMAPCOREINFO
*
)
info
)
->
bmciColors
[
i
].
rgbtGreen
;
colorTable
[
i
].
rgbBlue
=
((
const
BITMAPCOREINFO
*
)
info
)
->
bmciColors
[
i
].
rgbtBlue
;
colorTable
[
i
].
rgbReserved
=
0
;
}
}
else
{
memcpy
(
colorTable
,
(
const
BYTE
*
)
info
+
(
WORD
)
info
->
bmiHeader
.
biSize
,
colors
*
sizeof
(
RGBQUAD
));
}
}
else
{
PALETTEOBJ
*
palette
;
const
WORD
*
index
=
(
const
WORD
*
)
((
const
BYTE
*
)
info
+
(
WORD
)
info
->
bmiHeader
.
biSize
);
if
((
palette
=
GDI_GetObjPtr
(
dc
->
hPalette
,
PALETTE_MAGIC
)))
{
UINT
entries
=
palette
->
logpalette
.
palNumEntries
;
for
(
i
=
0
;
i
<
colors
;
i
++
,
index
++
)
{
PALETTEENTRY
*
entry
=
&
palette
->
logpalette
.
palPalEntry
[
*
index
%
entries
];
colorTable
[
i
].
rgbRed
=
entry
->
peRed
;
colorTable
[
i
].
rgbGreen
=
entry
->
peGreen
;
colorTable
[
i
].
rgbBlue
=
entry
->
peBlue
;
colorTable
[
i
].
rgbReserved
=
0
;
}
GDI_ReleaseObj
(
dc
->
hPalette
);
}
}
bmp
->
color_table
=
colorTable
;
bmp
->
nb_colors
=
colors
;
}
/***********************************************************************
* CreateDIBSection (GDI32.@)
*/
...
...
@@ -1260,6 +1344,8 @@ HBITMAP WINAPI CreateDIBSection(HDC hdc, CONST BITMAPINFO *bmi, UINT usage,
{
bmp
->
dib
=
dib
;
bmp
->
funcs
=
dc
->
funcs
;
/* create local copy of DIB palette */
if
(
bpp
<=
8
)
DIB_CopyColorTable
(
dc
,
bmp
,
usage
,
bmi
);
GDI_ReleaseObj
(
ret
);
if
(
dc
->
funcs
->
pCreateDIBSection
)
...
...
dlls/gdi32/gdi_private.h
View file @
f7ffbe45
...
...
@@ -324,6 +324,8 @@ typedef struct tagBITMAPOBJ
/* For device-independent bitmaps: */
DIBSECTION
*
dib
;
SEGPTR
segptr_bits
;
/* segptr to DIB bits */
RGBQUAD
*
color_table
;
/* DIB color table if <= 8bpp */
UINT
nb_colors
;
/* number of colors in table */
}
BITMAPOBJ
;
/* bidi.c */
...
...
dlls/gdi32/tests/bitmap.c
View file @
f7ffbe45
...
...
@@ -1096,10 +1096,7 @@ static void test_GetDIBits_selected_DIB(UINT bpp)
break
;
}
}
todo_wine
{
ok
(
equalContents
,
"GetDIBits with DIB selected in DC: Invalid DIB color table
\n
"
);
}
ok
(
equalContents
,
"GetDIBits with DIB selected in DC: Invalid DIB color table
\n
"
);
equalContents
=
TRUE
;
for
(
i
=
0
;
i
<
dib_size
/
sizeof
(
DWORD
);
i
++
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment