实现方法
func Color16ToRGB(colorStr string) (red, green, blue int, err error) {
color64, err := strconv.ParseInt(strings.TrimPrefix(colorStr, "#"), 16, 32)
if err != nil {
return
}
colorInt := int(color64)
return colorInt >> 16, (colorInt & 0x00FF00) >> 8, colorInt & 0x0000FF, nil
}
使用方法
fmt.Println(Color16ToRGB("#003366"))

浙公网安备 33010602011771号