How to get image from random byte array

Viewed 56

I'm working with decoder for Apple CarPlay which originally is using WebRTC and html video as display for it. I'm trying to replace html with Fyne image refresh.

Current source code looks like that

duration := time.Duration((float32(1) / float32(fps)) * float32(time.Second))

if videoTrack != nil {
    videoTrack.WriteSample(media.Sample{Data: data.Data, Duration: duration})
}

where videoTrack is:

videoTrack       *webrtc.TrackLocalStaticSample

I've tried to move data.Data (since it's byte[]) into image converter, but I guess there's some more for that.

Im looking for some help in transporting these byte[] into image compression because that's the format Fyne is using, but without any success. Can anyone give me some hint in that?

1 Answers

You can either load the byte[] to an image using standard go image package (blocking operation) or you can pass it to Fyne as a resource). To do the latter try canvas.NewImageFromResource(fyne.NewStaticResource(“streamName.png”, data)).

After this setup you can set the Image or Resource on your image and call 'Refresh()` to update the display.

Related