mirror of
https://github.com/talgo-cloud/talgo-libwebp.git
synced 2026-03-17 11:16:30 -07:00
Update comments
This commit is contained in:
parent
c356a8c12f
commit
fab8f03740
5 changed files with 28 additions and 16 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
// Package main is an example implementation of WebP decoder.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
// Package main is an example implementation of WebP encoder.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -17,19 +17,20 @@ import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DecoderOptions specifies decoding options
|
// DecoderOptions specifies decoding options of WebP.
|
||||||
type DecoderOptions struct {
|
type DecoderOptions struct {
|
||||||
BypassFiltering bool
|
BypassFiltering bool // If true, bypass filtering process
|
||||||
NoFancyUpsampling bool
|
NoFancyUpsampling bool // If true, do not fancy upsampling
|
||||||
Crop image.Rectangle
|
Crop image.Rectangle // Do cropping if image.Rectangle is not empty.
|
||||||
Scale image.Rectangle
|
Scale image.Rectangle // Do scaling if image.Rectangle is not empty.
|
||||||
UseThreads bool
|
UseThreads bool // If true, use multi threads
|
||||||
DitheringStrength int
|
DitheringStrength int // Specify dithering strength [0=Off .. 100=full]
|
||||||
Flip bool
|
Flip bool // If true, flip output vertically
|
||||||
AlphaDitheringStrength int
|
AlphaDitheringStrength int // Specify alpha dithering strength in [0..100]
|
||||||
}
|
}
|
||||||
|
|
||||||
// BitstreamFeatures retrived from data stream.
|
// BitstreamFeatures represents the image properties which are retrived from
|
||||||
|
// data stream.
|
||||||
type BitstreamFeatures struct {
|
type BitstreamFeatures struct {
|
||||||
Width int // Image width in pixels
|
Width int // Image width in pixels
|
||||||
Height int // Image height in pixles
|
Height int // Image height in pixles
|
||||||
|
|
@ -52,7 +53,7 @@ func GetInfo(data []byte) (width, height int) {
|
||||||
return int(w), int(h)
|
return int(w), int(h)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFeatures returns features retrived from data stream.
|
// GetFeatures returns features as BitstreamFeatures retrived from data stream.
|
||||||
func GetFeatures(data []byte) (f *BitstreamFeatures, err error) {
|
func GetFeatures(data []byte) (f *BitstreamFeatures, err error) {
|
||||||
var cf C.WebPBitstreamFeatures
|
var cf C.WebPBitstreamFeatures
|
||||||
status := C.WebPGetFeatures((*C.uint8_t)(&data[0]), (C.size_t)(len(data)), &cf)
|
status := C.WebPGetFeatures((*C.uint8_t)(&data[0]), (C.size_t)(len(data)), &cf)
|
||||||
|
|
@ -72,7 +73,8 @@ func GetFeatures(data []byte) (f *BitstreamFeatures, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecodeYUVA decodes WebP image into YUV image with alpha channel.
|
// DecodeYUVA decodes WebP image into YUV image with alpha channel, and returns
|
||||||
|
// it as *YUVAImage.
|
||||||
func DecodeYUVA(data []byte, options *DecoderOptions) (img *YUVAImage, err error) {
|
func DecodeYUVA(data []byte, options *DecoderOptions) (img *YUVAImage, err error) {
|
||||||
config, err := initDecoderConfig(options)
|
config, err := initDecoderConfig(options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -127,7 +129,7 @@ func DecodeYUVA(data []byte, options *DecoderOptions) (img *YUVAImage, err error
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecodeRGBA decodes WebP image into RGBA image.
|
// DecodeRGBA decodes WebP image into RGBA image and returns it as an *image.RGBA.
|
||||||
func DecodeRGBA(data []byte, options *DecoderOptions) (img *image.RGBA, err error) {
|
func DecodeRGBA(data []byte, options *DecoderOptions) (img *image.RGBA, err error) {
|
||||||
config, err := initDecoderConfig(options)
|
config, err := initDecoderConfig(options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Package webp provides an interface to libwebp library to decoding/encoding
|
||||||
|
// WebP image.
|
||||||
package webp
|
package webp
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -19,7 +21,7 @@ const (
|
||||||
YUV420A ColorSpace = C.WEBP_YUV420A
|
YUV420A ColorSpace = C.WEBP_YUV420A
|
||||||
)
|
)
|
||||||
|
|
||||||
// Preset corresponds to C.WebPPreset
|
// Preset corresponds to C.WebPPreset.
|
||||||
type Preset int
|
type Preset int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,16 @@ import "image"
|
||||||
|
|
||||||
// YUVAImage represents a image of YUV colors with alpha channel image.
|
// YUVAImage represents a image of YUV colors with alpha channel image.
|
||||||
//
|
//
|
||||||
// We can not insert WebP planer image into image.YCbCr,
|
// YUVAImage contains decoded YCbCr image data with alpha channel,
|
||||||
// because image.YCbCr is not compatible with ITU-R BT.601, but JFIF/JPEG one.
|
// but it is not compatible with image.YCbCr. Because, the RGB-YCbCr conversion
|
||||||
|
// that used in WebP is following to ITU-R BT.601 standard.
|
||||||
|
// In contrast, the conversion of Image.YCbCr (and color.YCbCrModel) is following
|
||||||
|
// to the JPEG standard (JFIF). If you need the image as image.YCBCr, you will
|
||||||
|
// first convert from WebP to RGB image, then convert from RGB image to JPEG's
|
||||||
|
// YCbCr image.
|
||||||
//
|
//
|
||||||
// See: http://en.wikipedia.org/wiki/YCbCr
|
// See: http://en.wikipedia.org/wiki/YCbCr
|
||||||
|
//
|
||||||
type YUVAImage struct {
|
type YUVAImage struct {
|
||||||
Y, Cb, Cr, A []uint8
|
Y, Cb, Cr, A []uint8
|
||||||
YStride int
|
YStride int
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue