Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
e536a128
Commit
e536a128
authored
Jul 24, 2012
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Jul 26, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdiplus: Store device resolution in the graphics object.
parent
96978295
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
26 deletions
+60
-26
gdiplus_private.h
dlls/gdiplus/gdiplus_private.h
+1
-0
graphics.c
dlls/gdiplus/graphics.c
+24
-26
image.c
dlls/gdiplus/image.c
+4
-0
image.c
dlls/gdiplus/tests/image.c
+31
-0
No files found.
dlls/gdiplus/gdiplus_private.h
View file @
e536a128
...
...
@@ -156,6 +156,7 @@ struct GpGraphics{
TextRenderingHint
texthint
;
GpUnit
unit
;
/* page unit */
REAL
scale
;
/* page scale */
REAL
xres
,
yres
;
GpMatrix
*
worldtrans
;
/* world transform */
BOOL
busy
;
/* hdc handle obtained by GdipGetDC */
GpRegion
*
clip
;
...
...
dlls/gdiplus/graphics.c
View file @
e536a128
...
...
@@ -84,12 +84,6 @@ static BYTE convert_path_point_type(BYTE type)
return
ret
;
}
static
REAL
graphics_res
(
GpGraphics
*
graphics
)
{
if
(
graphics
->
image
)
return
graphics
->
image
->
xres
;
else
return
(
REAL
)
GetDeviceCaps
(
graphics
->
hdc
,
LOGPIXELSX
);
}
static
COLORREF
get_gdi_brush_color
(
const
GpBrush
*
brush
)
{
ARGB
argb
;
...
...
@@ -260,7 +254,7 @@ static INT prepare_dc(GpGraphics *graphics, GpPen *pen)
width
=
sqrt
((
pt
[
1
].
X
-
pt
[
0
].
X
)
*
(
pt
[
1
].
X
-
pt
[
0
].
X
)
+
(
pt
[
1
].
Y
-
pt
[
0
].
Y
)
*
(
pt
[
1
].
Y
-
pt
[
0
].
Y
))
/
sqrt
(
2
.
0
);
width
*=
pen
->
width
*
convert_unit
(
graphics
_res
(
graphics
)
,
width
*=
pen
->
width
*
convert_unit
(
graphics
->
xres
,
pen
->
unit
==
UnitWorld
?
graphics
->
unit
:
pen
->
unit
);
}
...
...
@@ -313,18 +307,22 @@ static GpStatus get_graphics_transform(GpGraphics *graphics, GpCoordinateSpace d
static
void
transform_and_round_points
(
GpGraphics
*
graphics
,
POINT
*
pti
,
GpPointF
*
ptf
,
INT
count
)
{
REAL
unitscale
;
REAL
scale_x
,
scale_y
;
GpMatrix
*
matrix
;
int
i
;
unitscale
=
convert_unit
(
graphics_res
(
graphics
),
graphics
->
unit
);
scale_x
=
convert_unit
(
graphics
->
xres
,
graphics
->
unit
);
scale_y
=
convert_unit
(
graphics
->
yres
,
graphics
->
unit
);
/* apply page scale */
if
(
graphics
->
unit
!=
UnitDisplay
)
unitscale
*=
graphics
->
scale
;
{
scale_x
*=
graphics
->
scale
;
scale_y
*=
graphics
->
scale
;
}
GdipCloneMatrix
(
graphics
->
worldtrans
,
&
matrix
);
GdipScaleMatrix
(
matrix
,
unitscale
,
unitscale
,
MatrixOrderAppend
);
GdipScaleMatrix
(
matrix
,
scale_x
,
scale_y
,
MatrixOrderAppend
);
GdipTransformMatrixPoints
(
matrix
,
ptf
,
count
);
GdipDeleteMatrix
(
matrix
);
...
...
@@ -2200,6 +2198,8 @@ GpStatus WINGDIPAPI GdipCreateFromHDC2(HDC hdc, HANDLE hDevice, GpGraphics **gra
(
*
graphics
)
->
compmode
=
CompositingModeSourceOver
;
(
*
graphics
)
->
unit
=
UnitDisplay
;
(
*
graphics
)
->
scale
=
1
.
0
;
(
*
graphics
)
->
xres
=
GetDeviceCaps
(
hdc
,
LOGPIXELSX
);
(
*
graphics
)
->
yres
=
GetDeviceCaps
(
hdc
,
LOGPIXELSY
);
(
*
graphics
)
->
busy
=
FALSE
;
(
*
graphics
)
->
textcontrast
=
4
;
list_init
(
&
(
*
graphics
)
->
containers
);
...
...
@@ -2239,6 +2239,8 @@ GpStatus graphics_from_image(GpImage *image, GpGraphics **graphics)
(
*
graphics
)
->
compmode
=
CompositingModeSourceOver
;
(
*
graphics
)
->
unit
=
UnitDisplay
;
(
*
graphics
)
->
scale
=
1
.
0
;
(
*
graphics
)
->
xres
=
image
->
xres
;
(
*
graphics
)
->
yres
=
image
->
yres
;
(
*
graphics
)
->
busy
=
FALSE
;
(
*
graphics
)
->
textcontrast
=
4
;
list_init
(
&
(
*
graphics
)
->
containers
);
...
...
@@ -5792,11 +5794,7 @@ GpStatus WINGDIPAPI GdipGetDpiX(GpGraphics *graphics, REAL* dpi)
if
(
graphics
->
busy
)
return
ObjectBusy
;
if
(
graphics
->
image
)
*
dpi
=
graphics
->
image
->
xres
;
else
*
dpi
=
(
REAL
)
GetDeviceCaps
(
graphics
->
hdc
,
LOGPIXELSX
);
*
dpi
=
graphics
->
xres
;
return
Ok
;
}
...
...
@@ -5810,11 +5808,7 @@ GpStatus WINGDIPAPI GdipGetDpiY(GpGraphics *graphics, REAL* dpi)
if
(
graphics
->
busy
)
return
ObjectBusy
;
if
(
graphics
->
image
)
*
dpi
=
graphics
->
image
->
yres
;
else
*
dpi
=
(
REAL
)
GetDeviceCaps
(
graphics
->
hdc
,
LOGPIXELSY
);
*
dpi
=
graphics
->
yres
;
return
Ok
;
}
...
...
@@ -5999,14 +5993,18 @@ static GpStatus get_graphics_transform(GpGraphics *graphics, GpCoordinateSpace d
GpCoordinateSpace
src_space
,
GpMatrix
**
matrix
)
{
GpStatus
stat
=
GdipCreateMatrix
(
matrix
);
REAL
unitscale
;
REAL
scale_x
,
scale_y
;
if
(
dst_space
!=
src_space
&&
stat
==
Ok
)
{
unitscale
=
convert_unit
(
graphics_res
(
graphics
),
graphics
->
unit
);
scale_x
=
convert_unit
(
graphics
->
xres
,
graphics
->
unit
);
scale_y
=
convert_unit
(
graphics
->
yres
,
graphics
->
unit
);
if
(
graphics
->
unit
!=
UnitDisplay
)
unitscale
*=
graphics
->
scale
;
{
scale_x
*=
graphics
->
scale
;
scale_y
*=
graphics
->
scale
;
}
/* transform from src_space to CoordinateSpacePage */
switch
(
src_space
)
...
...
@@ -6017,7 +6015,7 @@ static GpStatus get_graphics_transform(GpGraphics *graphics, GpCoordinateSpace d
case
CoordinateSpacePage
:
break
;
case
CoordinateSpaceDevice
:
GdipScaleMatrix
(
*
matrix
,
1
.
0
/
unitscale
,
1
.
0
/
unitscale
,
MatrixOrderAppend
);
GdipScaleMatrix
(
*
matrix
,
1
.
0
/
scale_x
,
1
.
0
/
scale_y
,
MatrixOrderAppend
);
break
;
}
...
...
@@ -6040,7 +6038,7 @@ static GpStatus get_graphics_transform(GpGraphics *graphics, GpCoordinateSpace d
case
CoordinateSpacePage
:
break
;
case
CoordinateSpaceDevice
:
GdipScaleMatrix
(
*
matrix
,
unitscale
,
unitscale
,
MatrixOrderAppend
);
GdipScaleMatrix
(
*
matrix
,
scale_x
,
scale_y
,
MatrixOrderAppend
);
break
;
}
}
...
...
dlls/gdiplus/image.c
View file @
e536a128
...
...
@@ -2305,7 +2305,11 @@ GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image,
stat
=
GdipCreateFromHDC
(
hdc
,
graphics
);
if
(
stat
==
Ok
)
{
(
*
graphics
)
->
image
=
image
;
(
*
graphics
)
->
xres
=
image
->
xres
;
(
*
graphics
)
->
yres
=
image
->
yres
;
}
}
else
if
(
image
->
type
==
ImageTypeMetafile
)
stat
=
METAFILE_GetGraphicsContext
((
GpMetafile
*
)
image
,
graphics
);
...
...
dlls/gdiplus/tests/image.c
View file @
e536a128
...
...
@@ -1517,6 +1517,7 @@ static void test_resolution(void)
{
GpStatus
stat
;
GpBitmap
*
bitmap
;
GpGraphics
*
graphics
;
REAL
res
=-
1
.
0
;
HDC
screendc
;
int
screenxres
,
screenyres
;
...
...
@@ -1560,6 +1561,15 @@ static void test_resolution(void)
expect
(
Ok
,
stat
);
expectf
((
REAL
)
screenyres
,
res
);
stat
=
GdipGetImageGraphicsContext
((
GpImage
*
)
bitmap
,
&
graphics
);
expect
(
Ok
,
stat
);
stat
=
GdipGetDpiX
(
graphics
,
&
res
);
expect
(
Ok
,
stat
);
expectf
((
REAL
)
screenxres
,
res
);
stat
=
GdipGetDpiY
(
graphics
,
&
res
);
expect
(
Ok
,
stat
);
expectf
((
REAL
)
screenyres
,
res
);
/* test changing the resolution */
stat
=
GdipBitmapSetResolution
(
bitmap
,
screenxres
*
2
.
0
,
screenyres
*
3
.
0
);
expect
(
Ok
,
stat
);
...
...
@@ -1572,6 +1582,27 @@ static void test_resolution(void)
expect
(
Ok
,
stat
);
expectf
(
screenyres
*
3
.
0
,
res
);
stat
=
GdipGetDpiX
(
graphics
,
&
res
);
expect
(
Ok
,
stat
);
expectf
((
REAL
)
screenxres
,
res
);
stat
=
GdipGetDpiY
(
graphics
,
&
res
);
expect
(
Ok
,
stat
);
expectf
((
REAL
)
screenyres
,
res
);
stat
=
GdipDeleteGraphics
(
graphics
);
expect
(
Ok
,
stat
);
stat
=
GdipGetImageGraphicsContext
((
GpImage
*
)
bitmap
,
&
graphics
);
expect
(
Ok
,
stat
);
stat
=
GdipGetDpiX
(
graphics
,
&
res
);
expect
(
Ok
,
stat
);
expectf
(
screenxres
*
2
.
0
,
res
);
stat
=
GdipGetDpiY
(
graphics
,
&
res
);
expect
(
Ok
,
stat
);
expectf
(
screenyres
*
3
.
0
,
res
);
stat
=
GdipDeleteGraphics
(
graphics
);
expect
(
Ok
,
stat
);
stat
=
GdipDisposeImage
((
GpImage
*
)
bitmap
);
expect
(
Ok
,
stat
);
}
...
...
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