@@ -17,14 +17,14 @@ import kotlinx.serialization.json.*
17
17
import net.mamoe.mirai.contact.nameCardOrNick
18
18
import net.mamoe.mirai.event.events.GroupMessageEvent
19
19
import net.mamoe.mirai.message.data.*
20
- import net.mamoe.mirai.utils.ExternalResource
21
20
import net.mamoe.mirai.utils.ExternalResource.Companion.toExternalResource
22
21
import net.mamoe.mirai.utils.ExternalResource.Companion.uploadAsImage
23
22
import net.mamoe.mirai.utils.MiraiLogger
24
23
import okhttp3.*
25
24
import org.apache.commons.lang3.StringUtils
26
25
import java.awt.image.BufferedImage
27
26
import java.io.ByteArrayInputStream
27
+ import java.io.ByteArrayOutputStream
28
28
import java.io.File
29
29
import java.util.concurrent.TimeUnit
30
30
import javax.imageio.ImageIO
@@ -106,21 +106,21 @@ object PicDetails {
106
106
}
107
107
108
108
if (" ugoira" .contentEquals(type)) {
109
- val toExternalResource = if (sanityLevel == 6 && Config .lowPoly){
110
- val byte = getUgoira(picId!! .toLong())
111
- LowPoly .generate(
112
- ByteArrayInputStream (byte),
113
- 200 ,
114
- 1F ,
115
- true ,
116
- " png" ,
117
- false ,
118
- 200
119
- ).toByteArray().toExternalResource()
120
- }else {
121
- getUgoira(picId!! .toLong())!! .toExternalResource()
122
- }
123
-
109
+ // val toExternalResource = if (sanityLevel == 6 && Config.lowPoly){
110
+ // val byte = getUgoira(picId!!.toLong())
111
+ // LowPoly.generate(
112
+ // ByteArrayInputStream(byte),
113
+ // 200,
114
+ // 1F,
115
+ // true,
116
+ // "png",
117
+ // false,
118
+ // 200
119
+ // ).toByteArray().toExternalResource()
120
+ // }else{
121
+ // getUgoira(picId!!.toLong())!!.toExternalResource()
122
+ // }
123
+ val toExternalResource = getUgoira(picId !! .toLong()) !! .toExternalResource()
124
124
val imageId: String = toExternalResource.uploadAsImage(event.group).imageId
125
125
withContext(Dispatchers .IO ) {
126
126
toExternalResource.close()
@@ -382,7 +382,28 @@ object PicDetails {
382
382
withContext(Dispatchers .IO ) {
383
383
ImageIO .read(File (dir.path + File .separator + " image" + File .separator + pic[i]))
384
384
} // 读入需要播放的jpg文件
385
- e.addFrame(src[i]) // 添加到帧中
385
+
386
+
387
+ val out = ByteArrayOutputStream ()
388
+ withContext(Dispatchers .IO ) {
389
+ ImageIO .write(src[i], " png" , out )
390
+ }
391
+ // val input: InputStream = ByteArrayInputStream(out.toByteArray())
392
+ e.addFrame(withContext(Dispatchers .IO ) {
393
+ ImageIO .read(
394
+ ByteArrayInputStream (
395
+ LowPoly .generate(
396
+ ByteArrayInputStream (out .toByteArray()),
397
+ 200 ,
398
+ 1F ,
399
+ true ,
400
+ " png" ,
401
+ false ,
402
+ 200
403
+ ).toByteArray()
404
+ )
405
+ )
406
+ }) // 添加到帧中
386
407
}
387
408
388
409
e.finish()
0 commit comments