Skip to content

Commit 9f884ae

Browse files
committed
Added PixFmt() getter
1 parent 2d72a27 commit 9f884ae

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Duration() float64
2929
FPS() float64
3030
Codec() string
3131
AudioCodec() string
32+
PixFmt() string
3233
FrameBuffer() []byte
3334
SetFrameBuffer(buffer []byte)
3435

imageio.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,17 @@ func Read(filename string) (int, int, []byte, error) {
1919
return 0, 0, nil, err
2020
}
2121
defer f.Close()
22+
2223
image, _, err := image.Decode(f)
2324
if err != nil {
2425
return 0, 0, nil, err
2526
}
27+
2628
bounds := image.Bounds().Max
27-
data := make([]byte, bounds.Y*bounds.X*3)
29+
size := bounds.X * bounds.Y * 3
30+
31+
data := make([]byte, size)
32+
2833
index := 0
2934
for h := 0; h < bounds.Y; h++ {
3035
for w := 0; w < bounds.X; w++ {
@@ -57,6 +62,7 @@ func Write(filename string, width, height int, data []byte) error {
5762
index += 3
5863
}
5964
}
65+
6066
if strings.HasSuffix(filename, ".png") {
6167
if err := png.Encode(f, image); err != nil {
6268
return err

video.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ func (video *Video) AudioCodec() string {
6969
return video.audioCodec
7070
}
7171

72+
func (video *Video) PixFmt() string {
73+
return video.pixfmt
74+
}
75+
7276
func (video *Video) FrameBuffer() []byte {
7377
return video.framebuffer
7478
}

0 commit comments

Comments
 (0)