|
54 | 54 | <div id="nav">
|
55 | 55 | <select id="files">
|
56 | 56 |
|
57 |
| - <option value="file0">github.com/gopherdojo/dojo8/kadai2/tanaka0325/imgconv/file.go (0.0%)</option> |
| 57 | + <option value="file0">github.com/gopherdojo/dojo8/kadai2/tanaka0325/imgconv/file.go (33.3%)</option> |
58 | 58 |
|
59 |
| - <option value="file1">github.com/gopherdojo/dojo8/kadai2/tanaka0325/imgconv/format.go (0.0%)</option> |
| 59 | + <option value="file1">github.com/gopherdojo/dojo8/kadai2/tanaka0325/imgconv/format.go (54.5%)</option> |
60 | 60 |
|
61 | 61 | <option value="file2">github.com/gopherdojo/dojo8/kadai2/tanaka0325/imgconv/imgconv.go (95.2%)</option>
|
62 | 62 |
|
|
84 | 84 | Create(string) (io.WriteCloser, error)
|
85 | 85 | }
|
86 | 86 |
|
87 |
| -type File struct { |
88 |
| - Reader io.Reader |
89 |
| - Writer io.Writer |
90 |
| -} |
| 87 | +type File struct{} |
91 | 88 |
|
92 | 89 | func (File) Open(n string) (io.ReadCloser, error) <span class="cov0" title="0">{ return os.Open(n) }</span>
|
93 | 90 | func (File) Create(n string) (io.WriteCloser, error) <span class="cov0" title="0">{ return os.Create(n) }</span>
|
94 | 91 |
|
95 |
| -func NewFile() File <span class="cov0" title="0">{ |
| 92 | +func NewFile() File <span class="cov8" title="1">{ |
96 | 93 | return File{}
|
97 | 94 | }</span>
|
98 | 95 | </pre>
|
|
133 | 130 |
|
134 | 131 | func (PNG) Decode(r io.Reader) (image.Image, error) <span class="cov0" title="0">{ return png.Decode(r) }</span>
|
135 | 132 | func (PNG) Encode(w io.Writer, i image.Image) error <span class="cov0" title="0">{ return png.Encode(w, i) }</span>
|
136 |
| -func (p *PNG) GetExt() string <span class="cov0" title="0">{ return p.Ext }</span> |
| 133 | +func (p *PNG) GetExt() string <span class="cov8" title="1">{ return p.Ext }</span> |
137 | 134 |
|
138 | 135 | // JPEG is type for jpeg format.
|
139 | 136 | type JPEG ImageFormat
|
140 | 137 |
|
141 | 138 | func (JPEG) Decode(r io.Reader) (image.Image, error) <span class="cov0" title="0">{ return jpeg.Decode(r) }</span>
|
142 | 139 | func (JPEG) Encode(w io.Writer, i image.Image) error <span class="cov0" title="0">{ return jpeg.Encode(w, i, nil) }</span>
|
143 |
| -func (j *JPEG) GetExt() string <span class="cov0" title="0">{ return j.Ext }</span> |
| 140 | +func (j *JPEG) GetExt() string <span class="cov8" title="1">{ return j.Ext }</span> |
144 | 141 |
|
145 | 142 | // GIF is type for gif format.
|
146 | 143 | type GIF ImageFormat
|
|
149 | 146 | func (GIF) Encode(w io.Writer, i image.Image) error <span class="cov0" title="0">{
|
150 | 147 | return gif.Encode(w, i, &gif.Options{NumColors: 256})
|
151 | 148 | }</span>
|
152 |
| -func (g *GIF) GetExt() string <span class="cov0" title="0">{ return g.Ext }</span> |
| 149 | +func (g *GIF) GetExt() string <span class="cov8" title="1">{ return g.Ext }</span> |
153 | 150 |
|
154 | 151 | // BMP is type for bmp format.
|
155 | 152 | type BMP ImageFormat
|
156 | 153 |
|
157 | 154 | func (BMP) Decode(r io.Reader) (image.Image, error) <span class="cov0" title="0">{ return bmp.Decode(r) }</span>
|
158 | 155 | func (BMP) Encode(w io.Writer, i image.Image) error <span class="cov0" title="0">{ return bmp.Encode(w, i) }</span>
|
159 |
| -func (b *BMP) GetExt() string <span class="cov0" title="0">{ return b.Ext }</span> |
| 156 | +func (b *BMP) GetExt() string <span class="cov8" title="1">{ return b.Ext }</span> |
160 | 157 |
|
161 | 158 | // TIFF is type for tiff format.
|
162 | 159 | type TIFF ImageFormat
|
163 | 160 |
|
164 | 161 | func (TIFF) Decode(r io.Reader) (image.Image, error) <span class="cov0" title="0">{ return tiff.Decode(r) }</span>
|
165 | 162 | func (TIFF) Encode(w io.Writer, i image.Image) error <span class="cov0" title="0">{ return tiff.Encode(w, i, nil) }</span>
|
166 |
| -func (t *TIFF) GetExt() string <span class="cov0" title="0">{ return t.Ext }</span> |
| 163 | +func (t *TIFF) GetExt() string <span class="cov8" title="1">{ return t.Ext }</span> |
167 | 164 |
|
168 |
| -func NewImageFormat(ext string) ImageFormater <span class="cov0" title="0">{ |
| 165 | +func NewImageFormat(ext string) ImageFormater <span class="cov8" title="1">{ |
169 | 166 | switch ext </span>{
|
170 |
| - case "png":<span class="cov0" title="0"> |
| 167 | + case "png":<span class="cov8" title="1"> |
171 | 168 | return &PNG{Ext: "png"}</span>
|
172 |
| - case "jpg", "jpeg":<span class="cov0" title="0"> |
| 169 | + case "jpg", "jpeg":<span class="cov8" title="1"> |
173 | 170 | return &JPEG{Ext: "jpeg"}</span>
|
174 |
| - case "gif":<span class="cov0" title="0"> |
| 171 | + case "gif":<span class="cov8" title="1"> |
175 | 172 | return &GIF{Ext: "gif"}</span>
|
176 |
| - case "bmp":<span class="cov0" title="0"> |
| 173 | + case "bmp":<span class="cov8" title="1"> |
177 | 174 | return &BMP{Ext: "bmp"}</span>
|
178 |
| - case "tiff", "tif":<span class="cov0" title="0"> |
| 175 | + case "tiff", "tif":<span class="cov8" title="1"> |
179 | 176 | return &TIFF{Ext: "tiff"}</span>
|
180 | 177 | }
|
181 | 178 |
|
182 |
| - <span class="cov0" title="0">return nil</span> |
| 179 | + <span class="cov8" title="1">return nil</span> |
183 | 180 | }
|
184 | 181 | </pre>
|
185 | 182 |
|
|
0 commit comments