-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpalettes.go
79 lines (70 loc) · 1.81 KB
/
palettes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package main
import (
"fmt"
"image"
"image/color"
"os"
)
const (
PaletteBGB = 2
)
const (
lightest = byte(iota)
light
dark
darkest
)
// Palettes is a mapping from colour palettes to their colour values
// to be used by the emulator.
var Palettes = [][][]byte{
// PaletteGreyscale
{
{0xFF, 0xFF, 0xFF},
{0xCC, 0xCC, 0xCC},
{0x77, 0x77, 0x77},
{0x00, 0x00, 0x00},
},
// PaletteOriginal
{
{0x9B, 0xBC, 0x0F},
{0x8B, 0xAC, 0x0F},
{0x30, 0x62, 0x30},
{0x0F, 0x38, 0x0F},
},
// PaletteBGB
{
{0xE0, 0xF8, 0xD0}, // lightest (#E0F8D0)
{0x88, 0xC0, 0x70}, // light (#88C070)
{0x34, 0x68, 0x56}, // dark (#346856)
{0x08, 0x18, 0x20}, // darkest (#081820)
},
}
// GetPaletteColour returns the colour based on the colour index and the currently
// selected palette.
func GetPaletteColour(index byte, palette byte) (uint8, uint8, uint8) {
col := Palettes[palette][index]
r, g, b := col[0], col[1], col[2]
return r, g, b
}
func checkColor(imData image.Image) {
// Make sure it is 32-bit RGBA color, each R,G,B, A component requires 8-bits
if imData.ColorModel() != color.RGBAModel {
fmt.Println("Not RGBA")
fmt.Println("Color model:", imData.ColorModel())
switch imData.ColorModel() {
case color.RGBAModel: // 32-bit RGBA color, each R,G,B, A component requires 8-bits
fmt.Println("RGBA")
case color.GrayModel: // 8-bit grayscale
fmt.Println("Gray")
case color.NRGBAModel: // 32-bit non-alpha-premultiplied RGB color, each R,G,B component requires 8-bits
fmt.Println("NRGBA")
case imData.ColorModel(): // 32-bit non-alpha-premultiplied YCbCr color, each Y,Cb,Cr component requires 8-bits
fmt.Println("NYCbCrA")
case color.YCbCrModel: // 24-bit YCbCr color, each Y,Cb,Cr component requires 8-bits
fmt.Println("YCbCr")
default:
fmt.Println("Unknown")
}
os.Exit(1)
}
}