Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
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
List
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
fallenstardust
YGOMobile
Commits
9dbf9968
Commit
9dbf9968
authored
Aug 23, 2018
by
fallenstardust
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/fallenstardust/YGOMobile-cn-ko-en
parents
eb6c9278
31077e3b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
104 additions
and
6 deletions
+104
-6
Classes/gframe/image_manager.cpp
Classes/gframe/image_manager.cpp
+103
-6
Classes/gframe/image_manager.h
Classes/gframe/image_manager.h
+1
-0
No files found.
Classes/gframe/image_manager.cpp
View file @
9dbf9968
...
...
@@ -83,18 +83,115 @@ void ImageManager::RemoveTexture(int code) {
tMap
.
erase
(
tit
);
}
}
// function by Warr1024, from https://github.com/minetest/minetest/issues/2419 , modified
void
imageScaleNNAA
(
irr
::
video
::
IImage
*
src
,
irr
::
video
::
IImage
*
dest
)
{
double
sx
,
sy
,
minsx
,
maxsx
,
minsy
,
maxsy
,
area
,
ra
,
ga
,
ba
,
aa
,
pw
,
ph
,
pa
;
u32
dy
,
dx
;
irr
::
video
::
SColor
pxl
;
// Cache rectsngle boundaries.
double
sw
=
src
->
getDimension
().
Width
*
1.0
;
double
sh
=
src
->
getDimension
().
Height
*
1.0
;
// Walk each destination image pixel.
// Note: loop y around x for better cache locality.
irr
::
core
::
dimension2d
<
u32
>
dim
=
dest
->
getDimension
();
for
(
dy
=
0
;
dy
<
dim
.
Height
;
dy
++
)
for
(
dx
=
0
;
dx
<
dim
.
Width
;
dx
++
)
{
// Calculate floating-point source rectangle bounds.
minsx
=
dx
*
sw
/
dim
.
Width
;
maxsx
=
minsx
+
sw
/
dim
.
Width
;
minsy
=
dy
*
sh
/
dim
.
Height
;
maxsy
=
minsy
+
sh
/
dim
.
Height
;
// Total area, and integral of r, g, b values over that area,
// initialized to zero, to be summed up in next loops.
area
=
0
;
ra
=
0
;
ga
=
0
;
ba
=
0
;
aa
=
0
;
// Loop over the integral pixel positions described by those bounds.
for
(
sy
=
floor
(
minsy
);
sy
<
maxsy
;
sy
++
)
for
(
sx
=
floor
(
minsx
);
sx
<
maxsx
;
sx
++
)
{
// Calculate width, height, then area of dest pixel
// that's covered by this source pixel.
pw
=
1
;
if
(
minsx
>
sx
)
pw
+=
sx
-
minsx
;
if
(
maxsx
<
(
sx
+
1
))
pw
+=
maxsx
-
sx
-
1
;
ph
=
1
;
if
(
minsy
>
sy
)
ph
+=
sy
-
minsy
;
if
(
maxsy
<
(
sy
+
1
))
ph
+=
maxsy
-
sy
-
1
;
pa
=
pw
*
ph
;
// Get source pixel and add it to totals, weighted
// by covered area and alpha.
pxl
=
src
->
getPixel
((
u32
)
sx
,
(
u32
)
sy
);
area
+=
pa
;
ra
+=
pa
*
pxl
.
getRed
();
ga
+=
pa
*
pxl
.
getGreen
();
ba
+=
pa
*
pxl
.
getBlue
();
aa
+=
pa
*
pxl
.
getAlpha
();
}
// Set the destination image pixel to the average color.
if
(
area
>
0
)
{
pxl
.
setRed
(
ra
/
area
+
0.5
);
pxl
.
setGreen
(
ga
/
area
+
0.5
);
pxl
.
setBlue
(
ba
/
area
+
0.5
);
pxl
.
setAlpha
(
aa
/
area
+
0.5
);
}
else
{
pxl
.
setRed
(
0
);
pxl
.
setGreen
(
0
);
pxl
.
setBlue
(
0
);
pxl
.
setAlpha
(
0
);
}
dest
->
setPixel
(
dx
,
dy
,
pxl
);
}
}
irr
::
video
::
ITexture
*
ImageManager
::
GetTextureFromFile
(
char
*
file
,
s32
width
,
s32
height
)
{
//if(mainGame->gameConf.use_image_scale) {
irr
::
video
::
ITexture
*
texture
;
irr
::
video
::
IImage
*
srcimg
=
driver
->
createImageFromFile
(
file
);
if
(
srcimg
==
NULL
)
return
NULL
;
if
(
srcimg
->
getDimension
()
==
irr
::
core
::
dimension2d
<
u32
>
(
width
,
height
))
{
texture
=
driver
->
addTexture
(
file
,
srcimg
);
}
else
{
video
::
IImage
*
destimg
=
driver
->
createImage
(
srcimg
->
getColorFormat
(),
irr
::
core
::
dimension2d
<
u32
>
(
width
,
height
));
imageScaleNNAA
(
srcimg
,
destimg
);
texture
=
driver
->
addTexture
(
file
,
destimg
);
destimg
->
drop
();
}
srcimg
->
drop
();
return
texture
;
//} else {
// return driver->getTexture(file);
//}
}
irr
::
video
::
ITexture
*
ImageManager
::
GetTexture
(
int
code
)
{
if
(
code
==
0
)
return
tUnknown
;
int
width
=
CARD_IMG_WIDTH
;
int
height
=
CARD_IMG_HEIGHT
;
auto
tit
=
tMap
.
find
(
code
);
if
(
tit
==
tMap
.
end
())
{
char
file
[
256
];
char
file_img
[
256
];
sprintf
(
file
,
"expansions/pics/%d.jpg"
,
code
);
irr
::
video
::
ITexture
*
img
=
NULL
;
std
::
list
<
std
::
string
>::
iterator
iter
;
for
(
iter
=
support_types
.
begin
();
iter
!=
support_types
.
end
();
++
iter
)
{
sprintf
(
file
,
"/expansions/pics/%d.%s"
,
code
,
iter
->
c_str
());
img
=
driver
->
getTexture
(
image_work_path
+
path
(
file
));
sprintf
(
file_img
,
"%s"
,
(
image_work_path
+
path
(
file
)).
c_str
());
img
=
GetTextureFromFile
(
file_img
,
width
,
height
);
if
(
img
!=
NULL
)
{
break
;
}
...
...
@@ -102,7 +199,7 @@ irr::video::ITexture* ImageManager::GetTexture(int code) {
if
(
img
==
NULL
)
{
for
(
iter
=
support_types
.
begin
();
iter
!=
support_types
.
end
();
++
iter
)
{
sprintf
(
file
,
"%s/%d.%s"
,
irr
::
android
::
getCardImagePath
(
mainGame
->
appMain
).
c_str
(),
code
,
iter
->
c_str
());
img
=
driver
->
getTexture
(
file
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
if
(
img
!=
NULL
)
{
break
;
}
...
...
@@ -165,18 +262,18 @@ irr::video::ITexture* ImageManager::GetTextureField(int code) {
if
(
tit
==
tFields
.
end
())
{
char
file
[
256
];
sprintf
(
file
,
"field/%s/%d.jpg"
,
irr
::
android
::
getCardImagePath
(
mainGame
->
appMain
).
c_str
(),
code
);
irr
::
video
::
ITexture
*
img
=
driver
->
getTexture
(
file
);
irr
::
video
::
ITexture
*
img
=
GetTextureFromFile
(
file
,
512
,
512
);
if
(
img
==
NULL
)
{
sprintf
(
file
,
"field/%s/%d.jpg"
,
irr
::
android
::
getCardImagePath
(
mainGame
->
appMain
).
c_str
(),
code
);
img
=
driver
->
getTexture
(
file
);
img
=
GetTextureFromFile
(
file
,
512
,
512
);
}
if
(
img
==
NULL
)
{
sprintf
(
file
,
"field/%s/%d.png"
,
irr
::
android
::
getCardImagePath
(
mainGame
->
appMain
).
c_str
(),
code
);
img
=
driver
->
getTexture
(
file
);
img
=
GetTextureFromFile
(
file
,
512
,
512
);
}
if
(
img
==
NULL
)
{
sprintf
(
file
,
"pics/field/%d.jpg"
,
code
);
img
=
driver
->
getTexture
(
file
);
img
=
GetTextureFromFile
(
file
,
512
,
512
);
if
(
img
==
NULL
)
{
tFields
[
code
]
=
NULL
;
return
NULL
;
...
...
Classes/gframe/image_manager.h
View file @
9dbf9968
...
...
@@ -15,6 +15,7 @@ public:
void
SetDevice
(
irr
::
IrrlichtDevice
*
dev
);
void
ClearTexture
();
void
RemoveTexture
(
int
code
);
irr
::
video
::
ITexture
*
GetTextureFromFile
(
char
*
file
,
s32
width
,
s32
height
);
irr
::
video
::
ITexture
*
GetTexture
(
int
code
);
irr
::
video
::
ITexture
*
GetTextureThumb
(
int
code
);
irr
::
video
::
ITexture
*
GetTextureField
(
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