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
895c6d8e
Commit
895c6d8e
authored
Aug 28, 2009
by
Vincent Povirk
Committed by
Alexandre Julliard
Aug 29, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdiplus: Use AlphaBlend for 32-bit images with alpha channels.
parent
7fdc0208
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
11 deletions
+82
-11
gdiplus.c
dlls/gdiplus/gdiplus.c
+19
-0
gdiplus_private.h
dlls/gdiplus/gdiplus_private.h
+3
-0
graphics.c
dlls/gdiplus/graphics.c
+60
-11
No files found.
dlls/gdiplus/gdiplus.c
View file @
895c6d8e
...
...
@@ -399,6 +399,25 @@ BOOL lengthen_path(GpPath *path, INT len)
return
TRUE
;
}
void
convert_32bppARGB_to_32bppPARGB
(
UINT
width
,
UINT
height
,
BYTE
*
dst_bits
,
INT
dst_stride
,
const
BYTE
*
src_bits
,
INT
src_stride
)
{
UINT
x
,
y
;
for
(
y
=
0
;
y
<
height
;
y
++
)
{
const
BYTE
*
src
=
src_bits
+
y
*
src_stride
;
BYTE
*
dst
=
dst_bits
+
y
*
dst_stride
;
for
(
x
=
0
;
x
<
width
;
x
++
)
{
BYTE
alpha
=
src
[
3
];
*
dst
++
=
*
src
++
*
alpha
/
255
;
*
dst
++
=
*
src
++
*
alpha
/
255
;
*
dst
++
=
*
src
++
*
alpha
/
255
;
*
dst
++
=
*
src
++
;
}
}
}
/* recursive deletion of GpRegion nodes */
inline
void
delete_element
(
region_element
*
element
)
{
...
...
dlls/gdiplus/gdiplus_private.h
View file @
895c6d8e
...
...
@@ -80,6 +80,9 @@ static inline REAL deg2rad(REAL degrees)
extern
const
char
*
debugstr_rectf
(
CONST
RectF
*
rc
);
extern
void
convert_32bppARGB_to_32bppPARGB
(
UINT
width
,
UINT
height
,
BYTE
*
dst_bits
,
INT
dst_stride
,
const
BYTE
*
src_bits
,
INT
src_stride
);
struct
GpPen
{
UINT
style
;
GpUnit
unit
;
...
...
dlls/gdiplus/graphics.c
View file @
895c6d8e
...
...
@@ -1877,8 +1877,8 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
{
HDC
hdc
;
GpBitmap
*
bitmap
=
(
GpBitmap
*
)
image
;
int
bm_is_selected
;
HBITMAP
old_hbm
=
NULL
;
int
temp_hdc
=
0
,
temp_bitmap
=
0
;
HBITMAP
hbitmap
,
old_hbm
=
NULL
;
if
(
srcUnit
==
UnitInch
)
dx
=
dy
=
96
.
0
;
/* FIXME: use the image resolution */
...
...
@@ -1887,24 +1887,73 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
else
return
NotImplemented
;
hdc
=
bitmap
->
hdc
;
bm_is_selected
=
(
hdc
!=
0
);
if
(
!
bm_is_selected
)
if
(
bitmap
->
format
==
PixelFormat32bppARGB
)
{
BITMAPINFOHEADER
bih
;
BYTE
*
temp_bits
;
/* we need a bitmap with premultiplied alpha */
hdc
=
CreateCompatibleDC
(
0
);
old_hbm
=
SelectObject
(
hdc
,
bitmap
->
hbitmap
);
temp_hdc
=
1
;
temp_bitmap
=
1
;
bih
.
biSize
=
sizeof
(
BITMAPINFOHEADER
);
bih
.
biWidth
=
bitmap
->
width
;
bih
.
biHeight
=
-
bitmap
->
height
;
bih
.
biPlanes
=
1
;
bih
.
biBitCount
=
32
;
bih
.
biCompression
=
BI_RGB
;
bih
.
biSizeImage
=
0
;
bih
.
biXPelsPerMeter
=
0
;
bih
.
biYPelsPerMeter
=
0
;
bih
.
biClrUsed
=
0
;
bih
.
biClrImportant
=
0
;
hbitmap
=
CreateDIBSection
(
hdc
,
(
BITMAPINFO
*
)
&
bih
,
DIB_RGB_COLORS
,
(
void
**
)
&
temp_bits
,
NULL
,
0
);
convert_32bppARGB_to_32bppPARGB
(
bitmap
->
width
,
bitmap
->
height
,
temp_bits
,
bitmap
->
width
*
4
,
bitmap
->
bits
,
bitmap
->
stride
);
}
else
{
hbitmap
=
bitmap
->
hbitmap
;
hdc
=
bitmap
->
hdc
;
temp_hdc
=
(
hdc
==
0
);
}
if
(
temp_hdc
)
{
if
(
!
hdc
)
hdc
=
CreateCompatibleDC
(
0
);
old_hbm
=
SelectObject
(
hdc
,
hbitmap
);
}
/* FIXME: maybe alpha blend depending on the format */
StretchBlt
(
graphics
->
hdc
,
pti
[
0
].
x
,
pti
[
0
].
y
,
pti
[
1
].
x
-
pti
[
0
].
x
,
pti
[
2
].
y
-
pti
[
0
].
y
,
hdc
,
srcx
*
dx
,
srcy
*
dy
,
srcwidth
*
dx
,
srcheight
*
dy
,
SRCCOPY
);
if
(
bitmap
->
format
==
PixelFormat32bppARGB
||
bitmap
->
format
==
PixelFormat32bppPARGB
)
{
BLENDFUNCTION
bf
;
bf
.
BlendOp
=
AC_SRC_OVER
;
bf
.
BlendFlags
=
0
;
bf
.
SourceConstantAlpha
=
255
;
bf
.
AlphaFormat
=
AC_SRC_ALPHA
;
GdiAlphaBlend
(
graphics
->
hdc
,
pti
[
0
].
x
,
pti
[
0
].
y
,
pti
[
1
].
x
-
pti
[
0
].
x
,
pti
[
2
].
y
-
pti
[
0
].
y
,
hdc
,
srcx
*
dx
,
srcy
*
dy
,
srcwidth
*
dx
,
srcheight
*
dy
,
bf
);
}
else
{
StretchBlt
(
graphics
->
hdc
,
pti
[
0
].
x
,
pti
[
0
].
y
,
pti
[
1
].
x
-
pti
[
0
].
x
,
pti
[
2
].
y
-
pti
[
0
].
y
,
hdc
,
srcx
*
dx
,
srcy
*
dy
,
srcwidth
*
dx
,
srcheight
*
dy
,
SRCCOPY
);
}
if
(
!
bm_is_selected
)
if
(
temp_hdc
)
{
SelectObject
(
hdc
,
old_hbm
);
DeleteDC
(
hdc
);
}
if
(
temp_bitmap
)
DeleteObject
(
hbitmap
);
}
else
{
...
...
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