| 74 | } |
| 75 | |
| 76 | func (d *decoder) processHeader() error { |
| 77 | |
| 78 | data, err := d.readHeader() |
| 79 | if err != nil { |
| 80 | return err |
| 81 | } |
| 82 | |
| 83 | header := string(data) |
| 84 | |
| 85 | if len(header) == 0 { |
| 86 | return nil |
| 87 | } |
| 88 | |
| 89 | params := strings.Split(header, ";") |
| 90 | |
| 91 | switch params[1] { |
| 92 | case "0", "1", "5", "6", "": |
| 93 | d.aspectRatio = 2 |
| 94 | case "2": |
| 95 | d.aspectRatio = 5 |
| 96 | case "3", "4": |
| 97 | d.aspectRatio = 3 |
| 98 | case "7", "8", "9": |
| 99 | d.aspectRatio = 1 |
| 100 | default: |
| 101 | return fmt.Errorf("invalid P1 in sixel header") |
| 102 | } |
| 103 | |
| 104 | if len(params) == 1 { |
| 105 | return nil |
| 106 | } |
| 107 | |
| 108 | switch params[1] { |
| 109 | case "0", "2", "": |
| 110 | // use the configured terminal background colour |
| 111 | case "1": |
| 112 | d.bg = color.RGBA{A: 0} // transparent bg |
| 113 | } |
| 114 | |
| 115 | // NOTE: we currently ignore P3 if it is specified |
| 116 | |
| 117 | if len(params) > 3 { |
| 118 | return fmt.Errorf("unexpected extra parameters in sixel header") |
| 119 | } |
| 120 | |
| 121 | return nil |
| 122 | } |
| 123 | |
| 124 | func (d *decoder) processBody() error { |
| 125 | |