MCPcopy Create free account
hub / github.com/FloatTech/ZeroBot-Plugin-Playground / loadpic

Method loadpic

plugin/draw/draw.go:432–460  ·  view source on GitHub ↗

编码看板娘图片和加载字体

()

Source from the content-addressed store, hash-verified

430
431// 编码看板娘图片和加载字体
432func (mp *mpic) loadpic() error {
433 if !file.IsExist(mp.font1) { // 获取字体
434 err := downloadData(text.BoldFontFile, "https://gitcode.net/u011570312/zbpdata/-/raw/main/"+text.BoldFontFile[5:]+"?inline=true")
435 if err != nil {
436 return err
437 }
438 }
439 if !file.IsExist(mp.font2) { // 获取字体
440 err := downloadData(text.SakuraFontFile, "https://gitcode.net/u011570312/zbpdata/-/raw/main/"+text.SakuraFontFile[5:]+"?inline=true")
441 if err != nil {
442 return err
443 }
444 }
445 if mp.isDisplay {
446 f, err := os.Open(mp.path)
447 if err != nil {
448 return err
449 }
450 defer f.Close()
451 mp.im, _, err = image.Decode(f)
452 if err != nil {
453 return err
454 }
455 mp.im = imgfactory.Limit(mp.im, 1280, 1280)
456 b := mp.im.Bounds().Size()
457 mp.w, mp.h = b.X, b.Y
458 }
459 return nil
460}
461
462// 下载数据,url=dataurl+path[5:]+"?inline=true"
463func downloadData(path, url string) error {

Callers 1

initFunction · 0.80

Calls 1

downloadDataFunction · 0.85

Tested by

no test coverage detected