Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
850134af
Unverified
Commit
850134af
authored
Jun 24, 2020
by
Rémi Verschelde
Committed by
GitHub
Jun 24, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #39617 from mrushyendra/bilinear_interpolation
Fix upscaling image with bilinear interpolation option specified
parents
057489b3
f24ec387
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
13 deletions
+14
-13
image.cpp
core/image.cpp
+14
-13
No files found.
core/image.cpp
View file @
850134af
...
@@ -678,34 +678,35 @@ static void _scale_bilinear(const uint8_t *__restrict p_src, uint8_t *__restrict
...
@@ -678,34 +678,35 @@ static void _scale_bilinear(const uint8_t *__restrict p_src, uint8_t *__restrict
enum
{
enum
{
FRAC_BITS
=
8
,
FRAC_BITS
=
8
,
FRAC_LEN
=
(
1
<<
FRAC_BITS
),
FRAC_LEN
=
(
1
<<
FRAC_BITS
),
FRAC_HALF
=
(
FRAC_LEN
>>
1
),
FRAC_MASK
=
FRAC_LEN
-
1
FRAC_MASK
=
FRAC_LEN
-
1
};
};
for
(
uint32_t
i
=
0
;
i
<
p_dst_height
;
i
++
)
{
for
(
uint32_t
i
=
0
;
i
<
p_dst_height
;
i
++
)
{
uint32_t
src_yofs_up_fp
=
(
i
*
p_src_height
*
FRAC_LEN
/
p_dst_height
);
// Add 0.5 in order to interpolate based on pixel center
uint32_t
src_yofs_
frac
=
src_yofs_up_fp
&
FRAC_MASK
;
uint32_t
src_yofs_
up_fp
=
(
i
+
0.5
)
*
p_src_height
*
FRAC_LEN
/
p_dst_height
;
uint32_t
src_yofs_up
=
src_yofs_up_fp
>>
FRAC_BITS
;
// Calculate nearest src pixel center above current, and truncate to get y index
uint32_t
src_yofs_up
=
src_yofs_up_fp
>=
FRAC_HALF
?
(
src_yofs_up_fp
-
FRAC_HALF
)
>>
FRAC_BITS
:
0
;
uint32_t
src_yofs_down
=
(
i
+
1
)
*
p_src_height
/
p_dst_height
;
uint32_t
src_yofs_down
=
(
src_yofs_up_fp
+
FRAC_HALF
)
>>
FRAC_BITS
;
if
(
src_yofs_down
>=
p_src_height
)
{
if
(
src_yofs_down
>=
p_src_height
)
{
src_yofs_down
=
p_src_height
-
1
;
src_yofs_down
=
p_src_height
-
1
;
}
}
// Calculate distance to pixel center of src_yofs_up
//src_yofs_up*=CC
;
uint32_t
src_yofs_frac
=
src_yofs_up_fp
&
FRAC_MASK
;
//src_yofs_down*=CC
;
src_yofs_frac
=
src_yofs_frac
>=
FRAC_HALF
?
src_yofs_frac
-
FRAC_HALF
:
src_yofs_frac
+
FRAC_HALF
;
uint32_t
y_ofs_up
=
src_yofs_up
*
p_src_width
*
CC
;
uint32_t
y_ofs_up
=
src_yofs_up
*
p_src_width
*
CC
;
uint32_t
y_ofs_down
=
src_yofs_down
*
p_src_width
*
CC
;
uint32_t
y_ofs_down
=
src_yofs_down
*
p_src_width
*
CC
;
for
(
uint32_t
j
=
0
;
j
<
p_dst_width
;
j
++
)
{
for
(
uint32_t
j
=
0
;
j
<
p_dst_width
;
j
++
)
{
uint32_t
src_xofs_left_fp
=
(
j
*
p_src_width
*
FRAC_LEN
/
p_dst_width
);
uint32_t
src_xofs_left_fp
=
(
j
+
0.5
)
*
p_src_width
*
FRAC_LEN
/
p_dst_width
;
uint32_t
src_xofs_frac
=
src_xofs_left_fp
&
FRAC_MASK
;
uint32_t
src_xofs_left
=
src_xofs_left_fp
>=
FRAC_HALF
?
(
src_xofs_left_fp
-
FRAC_HALF
)
>>
FRAC_BITS
:
0
;
uint32_t
src_xofs_left
=
src_xofs_left_fp
>>
FRAC_BITS
;
uint32_t
src_xofs_right
=
(
src_xofs_left_fp
+
FRAC_HALF
)
>>
FRAC_BITS
;
uint32_t
src_xofs_right
=
(
j
+
1
)
*
p_src_width
/
p_dst_width
;
if
(
src_xofs_right
>=
p_src_width
)
{
if
(
src_xofs_right
>=
p_src_width
)
{
src_xofs_right
=
p_src_width
-
1
;
src_xofs_right
=
p_src_width
-
1
;
}
}
uint32_t
src_xofs_frac
=
src_xofs_left_fp
&
FRAC_MASK
;
src_xofs_frac
=
src_xofs_frac
>=
FRAC_HALF
?
src_xofs_frac
-
FRAC_HALF
:
src_xofs_frac
+
FRAC_HALF
;
src_xofs_left
*=
CC
;
src_xofs_left
*=
CC
;
src_xofs_right
*=
CC
;
src_xofs_right
*=
CC
;
...
...
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