chenyachao

如果能帮到你,那是最好了

  :: 首页 :: 博问 :: 闪存 :: :: :: 订阅 订阅 :: 管理 ::

实现方法

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"))

 

posted on 2018-11-24 17:35  chenyachao  阅读(395)  评论(0编辑  收藏  举报