icns

Easily create .icns files (Mac Icons) with this Go library or the included CLI.
Log | Files | Refs | LICENSE

commit 0161855a44415f21c7d8969d701c3ebeb6aaabef
parent e0231ee9f2a56f813b950ae48d16329135df9e77
Author: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Date:   Tue, 29 Oct 2024 11:22:24 +0800

icns.ImageFormat: enumerate expected image formats

We don't support JPEG 2000, but we want to explicitly handle it for the
purpose of error reporting.

Signed-off-by: Jack Mordaunt <jackmordaunt.dev@gmail.com>

Diffstat:
Micns.go | 23+++++++++++++++++++++++
1 file changed, 23 insertions(+), 0 deletions(-)

diff --git a/icns.go b/icns.go @@ -2,6 +2,7 @@ package icns import ( "errors" + "fmt" "image" "io" "sync" @@ -143,12 +144,34 @@ func sizesFrom(max uint) []uint { return []uint{} } +// ImageFormat specifies the type of image data associated with an icon. +type ImageFormat int + +const ( + ImageFormatPNG ImageFormat = iota + ImageFormatJPEG2000 +) + +func (f ImageFormat) String() string { + switch f { + case ImageFormatPNG: + return "PNG" + case ImageFormatJPEG2000: + return "JPEG 2000" + } + return fmt.Sprintf("unknown format %d", f) +} + // OsType is a 4 character identifier used to differentiate icon types. type OsType struct { ID string Size uint } +func (t OsType) String() string { + return t.ID +} + var osTypes = []OsType{ {ID: "ic10", Size: uint(1024)}, {ID: "ic14", Size: uint(512)},