Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
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
MyCard
Mirai
Commits
8e97b47a
Commit
8e97b47a
authored
Oct 05, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small updates
parent
2d825992
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/CharImageConverter.kt
...vmMain/kotlin/net/mamoe/mirai/utils/CharImageConverter.kt
+6
-6
No files found.
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/CharImageConverter.kt
View file @
8e97b47a
package
net.mamoe.mirai.utils
package
net.mamoe.mirai.utils
import
java.awt.
*
import
java.awt.
Image
import
java.awt.image.BufferedImage
import
java.awt.image.BufferedImage
import
java.util.
ArrayList
import
java.util.
*
import
java.util.concurrent.Callable
import
java.util.concurrent.Callable
import
kotlin.math.max
import
kotlin.math.max
import
kotlin.math.min
import
kotlin.math.min
...
@@ -22,7 +22,7 @@ class CharImageConverter @JvmOverloads constructor(
...
@@ -22,7 +22,7 @@ class CharImageConverter @JvmOverloads constructor(
/*
/*
* resize Image
* resize Image
* */
* */
val
newHeight
=
(
this
.
image
!!
.
getHeight
()
*
(
width
.
toDouble
()
/
this
.
image
!!
.
getWidth
()
)).
toInt
()
val
newHeight
=
(
this
.
image
!!
.
height
*
(
width
.
toDouble
()
/
this
.
image
!!
.
width
)).
toInt
()
val
tmp
=
image
!!
.
getScaledInstance
(
width
,
newHeight
,
Image
.
SCALE_SMOOTH
)
val
tmp
=
image
!!
.
getScaledInstance
(
width
,
newHeight
,
Image
.
SCALE_SMOOTH
)
val
dimg
=
BufferedImage
(
width
,
newHeight
,
BufferedImage
.
TYPE_INT_ARGB
)
val
dimg
=
BufferedImage
(
width
,
newHeight
,
BufferedImage
.
TYPE_INT_ARGB
)
val
g2d
=
dimg
.
createGraphics
()
val
g2d
=
dimg
.
createGraphics
()
...
@@ -33,14 +33,14 @@ class CharImageConverter @JvmOverloads constructor(
...
@@ -33,14 +33,14 @@ class CharImageConverter @JvmOverloads constructor(
val
builder
=
StringBuilder
()
val
builder
=
StringBuilder
()
val
lines
=
ArrayList
<
StringBuilder
>(
this
.
image
!!
.
getHeight
()
)
val
lines
=
ArrayList
<
StringBuilder
>(
this
.
image
!!
.
height
)
var
minXPos
=
this
.
width
var
minXPos
=
this
.
width
var
maxXPos
=
0
var
maxXPos
=
0
for
(
y
in
0
until
image
!!
.
getHeight
()
)
{
for
(
y
in
0
until
image
!!
.
height
)
{
val
builderLine
=
StringBuilder
()
val
builderLine
=
StringBuilder
()
for
(
x
in
0
until
image
!!
.
getWidth
()
)
{
for
(
x
in
0
until
image
!!
.
width
)
{
val
gray
=
gray
(
image
!!
.
getRGB
(
x
,
y
))
val
gray
=
gray
(
image
!!
.
getRGB
(
x
,
y
))
if
(
grayCompare
(
gray
,
background
))
{
if
(
grayCompare
(
gray
,
background
))
{
builderLine
.
append
(
" "
)
builderLine
.
append
(
" "
)
...
...
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