Added PixFmt() getter
This commit is contained in:
parent
2d72a27288
commit
9f884aeec1
3 changed files with 12 additions and 1 deletions
|
@ -29,6 +29,7 @@ Duration() float64
|
|||
FPS() float64
|
||||
Codec() string
|
||||
AudioCodec() string
|
||||
PixFmt() string
|
||||
FrameBuffer() []byte
|
||||
SetFrameBuffer(buffer []byte)
|
||||
|
||||
|
|
|
@ -19,12 +19,17 @@ func Read(filename string) (int, int, []byte, error) {
|
|||
return 0, 0, nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
image, _, err := image.Decode(f)
|
||||
if err != nil {
|
||||
return 0, 0, nil, err
|
||||
}
|
||||
|
||||
bounds := image.Bounds().Max
|
||||
data := make([]byte, bounds.Y*bounds.X*3)
|
||||
size := bounds.X * bounds.Y * 3
|
||||
|
||||
data := make([]byte, size)
|
||||
|
||||
index := 0
|
||||
for h := 0; h < bounds.Y; h++ {
|
||||
for w := 0; w < bounds.X; w++ {
|
||||
|
@ -57,6 +62,7 @@ func Write(filename string, width, height int, data []byte) error {
|
|||
index += 3
|
||||
}
|
||||
}
|
||||
|
||||
if strings.HasSuffix(filename, ".png") {
|
||||
if err := png.Encode(f, image); err != nil {
|
||||
return err
|
||||
|
|
4
video.go
4
video.go
|
@ -69,6 +69,10 @@ func (video *Video) AudioCodec() string {
|
|||
return video.audioCodec
|
||||
}
|
||||
|
||||
func (video *Video) PixFmt() string {
|
||||
return video.pixfmt
|
||||
}
|
||||
|
||||
func (video *Video) FrameBuffer() []byte {
|
||||
return video.framebuffer
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue