Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
ygopro
Commits
dbaa047a
Commit
dbaa047a
authored
Feb 06, 2026
by
salix5
Committed by
GitHub
Feb 06, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pixel range in imageScaleNNAA, add use_threading param (#2969)
parent
bc8e65be
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
23 deletions
+28
-23
gframe/image_manager.cpp
gframe/image_manager.cpp
+28
-23
No files found.
gframe/image_manager.cpp
View file @
dbaa047a
#include "image_manager.h"
#include "image_manager.h"
#include "game.h"
#include "game.h"
#include <cmath>
#include <thread>
#include <thread>
#ifdef _OPENMP
#ifdef _OPENMP
#include <omp.h>
#include <omp.h>
...
@@ -120,57 +121,61 @@ void ImageManager::ResizeTexture() {
...
@@ -120,57 +121,61 @@ void ImageManager::ResizeTexture() {
tBackGround_deck
=
tBackGround
;
tBackGround_deck
=
tBackGround
;
}
}
// function by Warr1024, from https://github.com/minetest/minetest/issues/2419 , modified
// function by Warr1024, from https://github.com/minetest/minetest/issues/2419 , modified
void
imageScaleNNAA
(
irr
::
video
::
IImage
*
src
,
irr
::
video
::
IImage
*
dest
)
{
void
imageScaleNNAA
(
irr
::
video
::
IImage
*
src
,
irr
::
video
::
IImage
*
dest
,
bool
use_threading
)
{
const
auto
&
srcDim
=
src
->
getDimension
();
const
auto
&
srcDim
=
src
->
getDimension
();
const
auto
&
destDim
=
dest
->
getDimension
();
const
auto
&
destDim
=
dest
->
getDimension
();
if
(
destDim
.
Width
==
0
||
destDim
.
Height
==
0
)
return
;
// Cache scale ratios.
// Cache scale ratios.
const
double
rx
=
(
double
)
srcDim
.
Width
/
destDim
.
Width
;
const
double
rx
=
(
double
)
srcDim
.
Width
/
destDim
.
Width
;
const
double
ry
=
(
double
)
srcDim
.
Height
/
destDim
.
Height
;
const
double
ry
=
(
double
)
srcDim
.
Height
/
destDim
.
Height
;
#pragma omp parallel if(
mainGame->gameConf.use_image_scale_multi_thread
)
#pragma omp parallel if(
use_threading
)
{
{
double
sx
,
sy
,
minsx
,
maxsx
,
minsy
,
maxsy
,
area
,
ra
,
ga
,
ba
,
aa
,
pw
,
ph
,
pa
;
irr
::
video
::
SColor
pxl
,
npxl
;
// Walk each destination image pixel.
// Walk each destination image pixel.
#pragma omp for schedule(dynamic)
#pragma omp for schedule(dynamic)
for
(
irr
::
s32
dy
=
0
;
dy
<
(
irr
::
s32
)
destDim
.
Height
;
dy
++
)
{
for
(
irr
::
s32
dy
=
0
;
dy
<
(
irr
::
s32
)
destDim
.
Height
;
dy
++
)
{
for
(
irr
::
s32
dx
=
0
;
dx
<
(
irr
::
s32
)
destDim
.
Width
;
dx
++
)
{
for
(
irr
::
s32
dx
=
0
;
dx
<
(
irr
::
s32
)
destDim
.
Width
;
dx
++
)
{
// Calculate floating-point source rectangle bounds.
// Calculate floating-point source rectangle bounds.
minsx
=
dx
*
rx
;
double
minsx
=
dx
*
rx
;
maxsx
=
minsx
+
rx
;
double
maxsx
=
minsx
+
rx
;
minsy
=
dy
*
ry
;
double
minsy
=
dy
*
ry
;
maxsy
=
minsy
+
ry
;
double
maxsy
=
minsy
+
ry
;
irr
::
u32
sx_begin
=
(
irr
::
u32
)
std
::
floor
(
minsx
);
irr
::
u32
sx_end
=
(
irr
::
u32
)
std
::
ceil
(
maxsx
);
if
(
sx_end
>
srcDim
.
Width
)
sx_end
=
srcDim
.
Width
;
irr
::
u32
sy_begin
=
(
irr
::
u32
)
std
::
floor
(
minsy
);
irr
::
u32
sy_end
=
(
irr
::
u32
)
std
::
ceil
(
maxsy
);
if
(
sy_end
>
srcDim
.
Height
)
sy_end
=
srcDim
.
Height
;
// Total area, and integral of r, g, b values over that area,
// Total area, and integral of r, g, b values over that area,
// initialized to zero, to be summed up in next loops.
// initialized to zero, to be summed up in next loops.
area
=
0
;
double
area
=
0
,
ra
=
0
,
ga
=
0
,
ba
=
0
,
aa
=
0
;
ra
=
0
;
irr
::
video
::
SColor
pxl
,
npxl
;
ga
=
0
;
ba
=
0
;
aa
=
0
;
// Loop over the integral pixel positions described by those bounds.
// Loop over the integral pixel positions described by those bounds.
for
(
sy
=
floor
(
minsy
);
sy
<
maxsy
;
sy
++
)
{
for
(
irr
::
u32
sy
=
sy_begin
;
sy
<
sy_end
;
sy
++
)
{
for
(
sx
=
floor
(
minsx
);
sx
<
maxsx
;
sx
++
)
{
for
(
irr
::
u32
sx
=
sx_begin
;
sx
<
sx_end
;
sx
++
)
{
// Calculate width, height, then area of dest pixel
// Calculate width, height, then area of dest pixel
// that's covered by this source pixel.
// that's covered by this source pixel.
pw
=
1
;
double
pw
=
1
;
if
(
minsx
>
sx
)
if
(
minsx
>
sx
)
pw
+=
sx
-
minsx
;
pw
+=
sx
-
minsx
;
if
(
maxsx
<
(
sx
+
1
))
if
(
maxsx
<
(
sx
+
1
))
pw
+=
maxsx
-
sx
-
1
;
pw
+=
maxsx
-
sx
-
1
;
ph
=
1
;
double
ph
=
1
;
if
(
minsy
>
sy
)
if
(
minsy
>
sy
)
ph
+=
sy
-
minsy
;
ph
+=
sy
-
minsy
;
if
(
maxsy
<
(
sy
+
1
))
if
(
maxsy
<
(
sy
+
1
))
ph
+=
maxsy
-
sy
-
1
;
ph
+=
maxsy
-
sy
-
1
;
pa
=
pw
*
ph
;
double
pa
=
pw
*
ph
;
// Get source pixel and add it to totals, weighted
// Get source pixel and add it to totals, weighted
// by covered area and alpha.
// by covered area and alpha.
pxl
=
src
->
getPixel
(
(
irr
::
u32
)
sx
,
(
irr
::
u32
)
sy
);
pxl
=
src
->
getPixel
(
sx
,
sy
);
area
+=
pa
;
area
+=
pa
;
ra
+=
pa
*
pxl
.
getRed
();
ra
+=
pa
*
pxl
.
getRed
();
ga
+=
pa
*
pxl
.
getGreen
();
ga
+=
pa
*
pxl
.
getGreen
();
...
@@ -201,7 +206,7 @@ irr::video::ITexture* ImageManager::GetTextureFromFile(const char* file, irr::s3
...
@@ -201,7 +206,7 @@ irr::video::ITexture* ImageManager::GetTextureFromFile(const char* file, irr::s3
texture
=
driver
->
addTexture
(
file
,
srcimg
);
texture
=
driver
->
addTexture
(
file
,
srcimg
);
}
else
{
}
else
{
irr
::
video
::
IImage
*
destimg
=
driver
->
createImage
(
srcimg
->
getColorFormat
(),
irr
::
core
::
dimension2d
<
irr
::
u32
>
(
width
,
height
));
irr
::
video
::
IImage
*
destimg
=
driver
->
createImage
(
srcimg
->
getColorFormat
(),
irr
::
core
::
dimension2d
<
irr
::
u32
>
(
width
,
height
));
imageScaleNNAA
(
srcimg
,
destimg
);
imageScaleNNAA
(
srcimg
,
destimg
,
mainGame
->
gameConf
.
use_image_scale_multi_thread
);
texture
=
driver
->
addTexture
(
file
,
destimg
);
texture
=
driver
->
addTexture
(
file
,
destimg
);
destimg
->
drop
();
destimg
->
drop
();
}
}
...
@@ -260,7 +265,7 @@ irr::video::ITexture* ImageManager::GetBigPicture(int code, float zoom) {
...
@@ -260,7 +265,7 @@ irr::video::ITexture* ImageManager::GetBigPicture(int code, float zoom) {
}
else
{
}
else
{
auto
origsize
=
srcimg
->
getDimension
();
auto
origsize
=
srcimg
->
getDimension
();
irr
::
video
::
IImage
*
destimg
=
driver
->
createImage
(
srcimg
->
getColorFormat
(),
irr
::
core
::
dimension2d
<
irr
::
u32
>
(
origsize
.
Width
*
zoom
,
origsize
.
Height
*
zoom
));
irr
::
video
::
IImage
*
destimg
=
driver
->
createImage
(
srcimg
->
getColorFormat
(),
irr
::
core
::
dimension2d
<
irr
::
u32
>
(
origsize
.
Width
*
zoom
,
origsize
.
Height
*
zoom
));
imageScaleNNAA
(
srcimg
,
destimg
);
imageScaleNNAA
(
srcimg
,
destimg
,
mainGame
->
gameConf
.
use_image_scale_multi_thread
);
texture
=
driver
->
addTexture
(
file
,
destimg
);
texture
=
driver
->
addTexture
(
file
,
destimg
);
destimg
->
drop
();
destimg
->
drop
();
}
}
...
@@ -298,7 +303,7 @@ int ImageManager::LoadThumbThread() {
...
@@ -298,7 +303,7 @@ int ImageManager::LoadThumbThread() {
imageManager
.
tThumbLoadingMutex
.
unlock
();
imageManager
.
tThumbLoadingMutex
.
unlock
();
}
else
{
}
else
{
irr
::
video
::
IImage
*
destimg
=
imageManager
.
driver
->
createImage
(
img
->
getColorFormat
(),
irr
::
core
::
dimension2d
<
irr
::
u32
>
(
width
,
height
));
irr
::
video
::
IImage
*
destimg
=
imageManager
.
driver
->
createImage
(
img
->
getColorFormat
(),
irr
::
core
::
dimension2d
<
irr
::
u32
>
(
width
,
height
));
imageScaleNNAA
(
img
,
destimg
);
imageScaleNNAA
(
img
,
destimg
,
mainGame
->
gameConf
.
use_image_scale_multi_thread
);
img
->
drop
();
img
->
drop
();
imageManager
.
tThumbLoadingMutex
.
lock
();
imageManager
.
tThumbLoadingMutex
.
lock
();
if
(
imageManager
.
tThumbLoadingThreadRunning
)
if
(
imageManager
.
tThumbLoadingThreadRunning
)
...
...
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