Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions internal/common/transparent_to_white.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ func ConvertTransparentToWhite(input []byte) ([]byte, error) {
return nil, fmt.Errorf("解码图像失败: %v", err)
}

switch format {
case "jpeg", "jpg":
// JPEG格式不支持透明通道,直接返回原始数据
return input, nil
case "png":
// PNG格式需要处理透明通道
// 继续处理透明通道,将透明部分替换为白色
break
default:
return nil, fmt.Errorf("unsupported image format: %s", format)
}

// 处理透明通道,将透明部分替换为白色
bounds := img.Bounds()
width, height := bounds.Max.X, bounds.Max.Y
Expand Down
1 change: 1 addition & 0 deletions internal/handler/rm_static.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func RMStaticHandler(c iris.Context) {
url := strings.Replace(path, "rm-static_djicdn_com", "https://rm-static.djicdn.com", 1)
url = strings.Replace(url, "terra-cn-oss-cdn-public-pro_oss-cn-hangzhou_aliyuncs_com", "https://terra-cn-oss-cdn-public-pro.oss-cn-hangzhou.aliyuncs.com", 1)
url = strings.Replace(url, "pro-robomasters-hz-n5i3_oss-cn-hangzhou_aliyuncs_com", "https://pro-robomasters-hz-n5i3.oss-cn-hangzhou.aliyuncs.com", 1)
url = strings.Replace(url, "terra-us-pro-rm-prod-pub-us_s3_amazonaws_com", "https://terra-us-pro-rm-prod-pub-us.s3.amazonaws.com", 1)
// auto add scheme
if !strings.HasPrefix(url, "http") {
url = "https://" + url
Expand Down
1 change: 1 addition & 0 deletions internal/job/job_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ func replaceRMStatic(data []byte) []byte {
str = strings.ReplaceAll(str, "https://rm-static.djicdn.com", "/api/static/rm-static_djicdn_com")
str = strings.ReplaceAll(str, "https://terra-cn-oss-cdn-public-pro.oss-cn-hangzhou.aliyuncs.com", "/api/static/terra-cn-oss-cdn-public-pro_oss-cn-hangzhou_aliyuncs_com")
str = strings.ReplaceAll(str, "https://pro-robomasters-hz-n5i3.oss-cn-hangzhou.aliyuncs.com", "/api/static/pro-robomasters-hz-n5i3_oss-cn-hangzhou_aliyuncs_com")
str = strings.ReplaceAll(str, "https://terra-us-pro-rm-prod-pub-us.s3.amazonaws.com", "/api/static/terra-us-pro-rm-prod-pub-us_s3_amazonaws_com")
return []byte(str)
}