mirror of
https://github.com/gen2brain/cam2ip.git
synced 2025-12-15 11:58:33 +00:00
31 lines
516 B
Go
31 lines
516 B
Go
//go:build libjpeg
|
|
|
|
// Package image.
|
|
package image
|
|
|
|
import (
|
|
"image"
|
|
"io"
|
|
|
|
"github.com/pixiv/go-libjpeg/jpeg"
|
|
)
|
|
|
|
// NewDecoder returns a new Decoder.
|
|
func NewDecoder(r io.Reader) *Decoder {
|
|
return &Decoder{r}
|
|
}
|
|
|
|
// Decoder struct.
|
|
type Decoder struct {
|
|
r io.Reader
|
|
}
|
|
|
|
// Decode decodes image from JPEG.
|
|
func (d Decoder) Decode() (image.Image, error) {
|
|
return jpeg.Decode(d.r, &jpeg.DecoderOptions{
|
|
DCTMethod: jpeg.DCTIFast,
|
|
DisableFancyUpsampling: true,
|
|
DisableBlockSmoothing: true,
|
|
})
|
|
}
|