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
f89e4a0d
Commit
f89e4a0d
authored
Feb 04, 2026
by
wind2009
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'mercury/patch-image-4' into develop
parents
b6343774
afd7fbf4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
54 deletions
+74
-54
gframe/image_manager.cpp
gframe/image_manager.cpp
+70
-54
gframe/image_manager.h
gframe/image_manager.h
+4
-0
No files found.
gframe/image_manager.cpp
View file @
f89e4a0d
...
@@ -119,7 +119,8 @@ void ImageManager::ResizeTexture() {
...
@@ -119,7 +119,8 @@ void ImageManager::ResizeTexture() {
if
(
!
tBackGround_deck
)
if
(
!
tBackGround_deck
)
tBackGround_deck
=
tBackGround
;
tBackGround_deck
=
tBackGround
;
}
}
// function by Warr1024, from https://github.com/minetest/minetest/issues/2419 , modified
/** Scale image using nearest neighbor anti-aliasing.
* 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
)
{
const
auto
&
srcDim
=
src
->
getDimension
();
const
auto
&
srcDim
=
src
->
getDimension
();
const
auto
&
destDim
=
dest
->
getDimension
();
const
auto
&
destDim
=
dest
->
getDimension
();
...
@@ -192,22 +193,63 @@ void imageScaleNNAA(irr::video::IImage *src, irr::video::IImage *dest) {
...
@@ -192,22 +193,63 @@ void imageScaleNNAA(irr::video::IImage *src, irr::video::IImage *dest) {
}
}
}
// end of parallel region
}
// end of parallel region
}
}
irr
::
video
::
ITexture
*
ImageManager
::
GetTextureFromFile
(
const
char
*
file
,
irr
::
s32
width
,
irr
::
s32
height
)
{
/** Convert image to texture, resizing if needed.
irr
::
video
::
ITexture
*
texture
;
* @param name Texture name (Irrlicht texture key).
irr
::
video
::
IImage
*
srcimg
=
driver
->
createImageFromFile
(
file
);
* @param srcimg Source image; will be dropped by this function.
* @return Texture pointer. Remove via `driver->removeTexture` (do not `drop`). */
irr
::
video
::
ITexture
*
ImageManager
::
addTexture
(
const
char
*
name
,
irr
::
video
::
IImage
*
srcimg
,
irr
::
s32
width
,
irr
::
s32
height
)
{
if
(
srcimg
==
nullptr
)
if
(
srcimg
==
nullptr
)
return
nullptr
;
return
nullptr
;
irr
::
video
::
ITexture
*
texture
;
if
(
srcimg
->
getDimension
()
==
irr
::
core
::
dimension2d
<
irr
::
u32
>
(
width
,
height
))
{
if
(
srcimg
->
getDimension
()
==
irr
::
core
::
dimension2d
<
irr
::
u32
>
(
width
,
height
))
{
texture
=
driver
->
addTexture
(
fil
e
,
srcimg
);
texture
=
driver
->
addTexture
(
nam
e
,
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
);
texture
=
driver
->
addTexture
(
fil
e
,
destimg
);
texture
=
driver
->
addTexture
(
nam
e
,
destimg
);
destimg
->
drop
();
destimg
->
drop
();
}
}
srcimg
->
drop
();
srcimg
->
drop
();
return
texture
;
return
texture
;
}
}
/** Load image from file and convert to texture.
* @return Texture pointer. Remove via `driver->removeTexture` (do not `drop`). */
irr
::
video
::
ITexture
*
ImageManager
::
GetTextureFromFile
(
const
char
*
file
,
irr
::
s32
width
,
irr
::
s32
height
)
{
irr
::
video
::
IImage
*
img
=
driver
->
createImageFromFile
(
file
);
if
(
img
==
nullptr
)
{
return
nullptr
;
}
char
name
[
256
];
mysnprintf
(
name
,
"%s/%d_%d"
,
file
,
width
,
height
);
return
addTexture
(
name
,
img
,
width
,
height
);
}
/** Load card picture from `expansions` or `pics` folder.
* Files in the expansions directory have priority, allowing custom pictures to be loaded without modifying the original files.
* @return Image pointer. Must be dropped after use. */
irr
::
video
::
IImage
*
ImageManager
::
GetImage
(
int
code
)
{
char
file
[
256
];
mysnprintf
(
file
,
"expansions/pics/%d.jpg"
,
code
);
irr
::
video
::
IImage
*
img
=
driver
->
createImageFromFile
(
file
);
if
(
img
==
nullptr
)
{
mysnprintf
(
file
,
"pics/%d.jpg"
,
code
);
img
=
driver
->
createImageFromFile
(
file
);
}
return
img
;
}
/** Load card picture.
* @return Texture pointer. Remove via `driver->removeTexture` (do not `drop`). */
irr
::
video
::
ITexture
*
ImageManager
::
GetTexture
(
int
code
,
irr
::
s32
width
,
irr
::
s32
height
)
{
irr
::
video
::
IImage
*
img
=
GetImage
(
code
);
if
(
img
==
nullptr
)
{
return
nullptr
;
}
char
name
[
256
];
mysnprintf
(
name
,
"pics/%d/%d_%d"
,
code
,
width
,
height
);
return
addTexture
(
name
,
img
,
width
,
height
);
}
/** Load managed card picture texture.
* @param fit Resize to fit scale if true.
* @return Texture pointer. Should NOT be removed nor dropped. */
irr
::
video
::
ITexture
*
ImageManager
::
GetTexture
(
int
code
,
bool
fit
)
{
irr
::
video
::
ITexture
*
ImageManager
::
GetTexture
(
int
code
,
bool
fit
)
{
if
(
code
==
0
)
if
(
code
==
0
)
return
fit
?
tUnknownFit
:
tUnknown
;
return
fit
?
tUnknownFit
:
tUnknown
;
...
@@ -222,21 +264,17 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) {
...
@@ -222,21 +264,17 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) {
}
}
auto
tit
=
tMap
[
fit
?
1
:
0
].
find
(
code
);
auto
tit
=
tMap
[
fit
?
1
:
0
].
find
(
code
);
if
(
tit
==
tMap
[
fit
?
1
:
0
].
end
())
{
if
(
tit
==
tMap
[
fit
?
1
:
0
].
end
())
{
char
file
[
256
];
irr
::
video
::
ITexture
*
texture
=
GetTexture
(
code
,
width
,
height
);
mysnprintf
(
file
,
"expansions/pics/%d.jpg"
,
code
);
tMap
[
fit
?
1
:
0
][
code
]
=
texture
;
irr
::
video
::
ITexture
*
img
=
GetTextureFromFile
(
file
,
width
,
height
);
return
(
texture
==
nullptr
)
?
(
fit
?
tUnknownFit
:
tUnknown
)
:
texture
;
if
(
img
==
nullptr
)
{
mysnprintf
(
file
,
"pics/%d.jpg"
,
code
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
}
tMap
[
fit
?
1
:
0
][
code
]
=
img
;
return
(
img
==
nullptr
)
?
(
fit
?
tUnknownFit
:
tUnknown
)
:
img
;
}
}
if
(
tit
->
second
)
if
(
tit
->
second
)
return
tit
->
second
;
return
tit
->
second
;
else
else
return
fit
?
tUnknownFit
:
tUnknown
;
return
fit
?
tUnknownFit
:
tUnknown
;
}
}
/** Load managed card picture texture with zoom.
* @return Texture pointer. Should NOT be removed nor dropped. */
irr
::
video
::
ITexture
*
ImageManager
::
GetBigPicture
(
int
code
,
float
zoom
)
{
irr
::
video
::
ITexture
*
ImageManager
::
GetBigPicture
(
int
code
,
float
zoom
)
{
if
(
code
==
0
)
if
(
code
==
0
)
return
tUnknown
;
return
tUnknown
;
...
@@ -244,29 +282,15 @@ irr::video::ITexture* ImageManager::GetBigPicture(int code, float zoom) {
...
@@ -244,29 +282,15 @@ irr::video::ITexture* ImageManager::GetBigPicture(int code, float zoom) {
driver
->
removeTexture
(
tBigPicture
);
driver
->
removeTexture
(
tBigPicture
);
tBigPicture
=
nullptr
;
tBigPicture
=
nullptr
;
}
}
irr
::
video
::
ITexture
*
texture
;
irr
::
video
::
IImage
*
img
=
GetImage
(
code
);
char
file
[
256
];
if
(
img
==
nullptr
)
{
mysnprintf
(
file
,
"expansions/pics/%d.jpg"
,
code
);
irr
::
video
::
IImage
*
srcimg
=
driver
->
createImageFromFile
(
file
);
if
(
srcimg
==
nullptr
)
{
mysnprintf
(
file
,
"pics/%d.jpg"
,
code
);
srcimg
=
driver
->
createImageFromFile
(
file
);
}
if
(
srcimg
==
nullptr
)
{
return
tUnknown
;
return
tUnknown
;
}
}
if
(
zoom
==
1
)
{
char
name
[
256
];
texture
=
driver
->
addTexture
(
file
,
srcimg
);
mysnprintf
(
name
,
"pics/%d/big"
,
code
);
}
else
{
auto
origsize
=
img
->
getDimension
();
auto
origsize
=
srcimg
->
getDimension
();
tBigPicture
=
addTexture
(
name
,
img
,
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
));
return
tBigPicture
;
imageScaleNNAA
(
srcimg
,
destimg
);
texture
=
driver
->
addTexture
(
file
,
destimg
);
destimg
->
drop
();
}
srcimg
->
drop
();
tBigPicture
=
texture
;
return
texture
;
}
}
int
ImageManager
::
LoadThumbThread
()
{
int
ImageManager
::
LoadThumbThread
()
{
while
(
true
)
{
while
(
true
)
{
...
@@ -279,13 +303,7 @@ int ImageManager::LoadThumbThread() {
...
@@ -279,13 +303,7 @@ int ImageManager::LoadThumbThread() {
int
code
=
imageManager
.
tThumbLoadingCodes
.
front
();
int
code
=
imageManager
.
tThumbLoadingCodes
.
front
();
imageManager
.
tThumbLoadingCodes
.
pop
();
imageManager
.
tThumbLoadingCodes
.
pop
();
imageManager
.
tThumbLoadingMutex
.
unlock
();
imageManager
.
tThumbLoadingMutex
.
unlock
();
char
file
[
256
];
irr
::
video
::
IImage
*
img
=
imageManager
.
GetImage
(
code
);
mysnprintf
(
file
,
"expansions/pics/%d.jpg"
,
code
);
irr
::
video
::
IImage
*
img
=
imageManager
.
driver
->
createImageFromFile
(
file
);
if
(
img
==
nullptr
)
{
mysnprintf
(
file
,
"pics/%d.jpg"
,
code
);
img
=
imageManager
.
driver
->
createImageFromFile
(
file
);
}
if
(
img
!=
nullptr
)
{
if
(
img
!=
nullptr
)
{
int
width
=
CARD_THUMB_WIDTH
*
mainGame
->
xScale
;
int
width
=
CARD_THUMB_WIDTH
*
mainGame
->
xScale
;
int
height
=
CARD_THUMB_HEIGHT
*
mainGame
->
yScale
;
int
height
=
CARD_THUMB_HEIGHT
*
mainGame
->
yScale
;
...
@@ -316,6 +334,8 @@ int ImageManager::LoadThumbThread() {
...
@@ -316,6 +334,8 @@ int ImageManager::LoadThumbThread() {
}
}
return
0
;
return
0
;
}
}
/** Load managed card thumbnail texture.
* @return Texture pointer. Should NOT be removed nor dropped. */
irr
::
video
::
ITexture
*
ImageManager
::
GetTextureThumb
(
int
code
)
{
irr
::
video
::
ITexture
*
ImageManager
::
GetTextureThumb
(
int
code
)
{
if
(
code
==
0
)
if
(
code
==
0
)
return
tUnknownThumb
;
return
tUnknownThumb
;
...
@@ -323,15 +343,9 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
...
@@ -323,15 +343,9 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
if
(
tit
==
tThumb
.
end
()
&&
!
mainGame
->
gameConf
.
use_image_load_background_thread
)
{
if
(
tit
==
tThumb
.
end
()
&&
!
mainGame
->
gameConf
.
use_image_load_background_thread
)
{
int
width
=
CARD_THUMB_WIDTH
*
mainGame
->
xScale
;
int
width
=
CARD_THUMB_WIDTH
*
mainGame
->
xScale
;
int
height
=
CARD_THUMB_HEIGHT
*
mainGame
->
yScale
;
int
height
=
CARD_THUMB_HEIGHT
*
mainGame
->
yScale
;
char
file
[
256
];
irr
::
video
::
ITexture
*
texture
=
GetTexture
(
code
,
width
,
height
);
mysnprintf
(
file
,
"expansions/pics/%d.jpg"
,
code
);
tThumb
[
code
]
=
texture
;
irr
::
video
::
ITexture
*
img
=
GetTextureFromFile
(
file
,
width
,
height
);
return
(
texture
==
nullptr
)
?
tUnknownThumb
:
texture
;
if
(
img
==
NULL
)
{
mysnprintf
(
file
,
"pics/%d.jpg"
,
code
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
}
tThumb
[
code
]
=
img
;
return
(
img
==
NULL
)
?
tUnknownThumb
:
img
;
}
}
if
(
tit
==
tThumb
.
end
()
||
tit
->
second
==
tLoading
)
{
if
(
tit
==
tThumb
.
end
()
||
tit
->
second
==
tLoading
)
{
imageManager
.
tThumbLoadingMutex
.
lock
();
imageManager
.
tThumbLoadingMutex
.
lock
();
...
@@ -339,7 +353,7 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
...
@@ -339,7 +353,7 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
if
(
lit
!=
tThumbLoading
.
end
())
{
if
(
lit
!=
tThumbLoading
.
end
())
{
if
(
lit
->
second
!=
nullptr
)
{
if
(
lit
->
second
!=
nullptr
)
{
char
textureName
[
256
];
char
textureName
[
256
];
mysnprintf
(
textureName
,
"pics/%d
.jpg_thumbnail"
,
code
);
// not an actual file
mysnprintf
(
textureName
,
"pics/%d
/thumbnail"
,
code
);
irr
::
video
::
ITexture
*
texture
=
driver
->
addTexture
(
textureName
,
lit
->
second
);
// textures must be added in the main thread due to OpenGL
irr
::
video
::
ITexture
*
texture
=
driver
->
addTexture
(
textureName
,
lit
->
second
);
// textures must be added in the main thread due to OpenGL
lit
->
second
->
drop
();
lit
->
second
->
drop
();
tThumb
[
code
]
=
texture
;
tThumb
[
code
]
=
texture
;
...
@@ -367,6 +381,8 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
...
@@ -367,6 +381,8 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
else
else
return
tUnknownThumb
;
return
tUnknownThumb
;
}
}
/** Load managed duel field texture.
* @return Texture pointer. Should NOT be removed nor dropped. */
irr
::
video
::
ITexture
*
ImageManager
::
GetTextureField
(
int
code
)
{
irr
::
video
::
ITexture
*
ImageManager
::
GetTextureField
(
int
code
)
{
if
(
code
==
0
)
if
(
code
==
0
)
return
nullptr
;
return
nullptr
;
...
...
gframe/image_manager.h
View file @
f89e4a0d
...
@@ -10,12 +10,16 @@
...
@@ -10,12 +10,16 @@
namespace
ygo
{
namespace
ygo
{
class
ImageManager
{
class
ImageManager
{
private:
irr
::
video
::
ITexture
*
addTexture
(
const
char
*
name
,
irr
::
video
::
IImage
*
srcimg
,
irr
::
s32
width
,
irr
::
s32
height
);
public:
public:
bool
Initial
();
bool
Initial
();
void
SetDevice
(
irr
::
IrrlichtDevice
*
dev
);
void
SetDevice
(
irr
::
IrrlichtDevice
*
dev
);
void
ClearTexture
();
void
ClearTexture
();
void
ResizeTexture
();
void
ResizeTexture
();
irr
::
video
::
ITexture
*
GetTextureFromFile
(
const
char
*
file
,
irr
::
s32
width
,
irr
::
s32
height
);
irr
::
video
::
ITexture
*
GetTextureFromFile
(
const
char
*
file
,
irr
::
s32
width
,
irr
::
s32
height
);
irr
::
video
::
IImage
*
GetImage
(
int
code
);
irr
::
video
::
ITexture
*
GetTexture
(
int
code
,
irr
::
s32
width
,
irr
::
s32
height
);
irr
::
video
::
ITexture
*
GetTexture
(
int
code
,
bool
fit
=
false
);
irr
::
video
::
ITexture
*
GetTexture
(
int
code
,
bool
fit
=
false
);
irr
::
video
::
ITexture
*
GetBigPicture
(
int
code
,
float
zoom
);
irr
::
video
::
ITexture
*
GetBigPicture
(
int
code
,
float
zoom
);
irr
::
video
::
ITexture
*
GetTextureThumb
(
int
code
);
irr
::
video
::
ITexture
*
GetTextureThumb
(
int
code
);
...
...
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