英文:
How to get image from random byte array
问题
我正在使用解码器与原本使用WebRTC和HTML视频作为显示的Apple CarPlay进行工作。我正在尝试用Fyne图像刷新替换HTML。
当前的源代码如下:
duration := time.Duration((float32(1) / float32(fps)) * float32(time.Second))
if videoTrack != nil {
videoTrack.WriteSample(media.Sample{Data: data.Data, Duration: duration})
}
其中videoTrack是:
videoTrack *webrtc.TrackLocalStaticSample
我尝试将data.Data
(因为它是byte[])移入图像转换器,但我猜还需要做更多的工作。
我正在寻求一些帮助,将这些byte[]转换为图像压缩,因为这是Fyne使用的格式,但一直没有成功。有人可以给我一些提示吗?
英文:
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
得分: 1
你可以使用标准的Go image
包将byte[]
加载为图像(阻塞操作),或者将其作为资源传递给Fyne。要进行后者,请尝试使用canvas.NewImageFromResource(fyne.NewStaticResource("streamName.png", data))
。
设置完成后,你可以将Image
或Resource
设置为你的图像,并调用Refresh()
来更新显示。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论