This is an example of converting BigBuckBunny yuv420 data to HTML RGB representation YUV data can be expressed in HTML by using the following code(html.go).
yuv420p := yuv.NewYUV420p(width, height, yStride, uvStride)
rgbPlane := yuv420p.ConvertRGBA(y, u, v)
fmt.Println(`
<style>
.container { display: flex; flex-direction: row; }
.dot { width: 100%; width: 1px; }
.dot:before { content: ""; display: block; padding-top: 1px; }
</style>
`)
i := 0
for y := 0; y < height; y += 1 {
fmt.Println("<div class='container'>");
for x := 0; x < width; x += 1 {
rgba := rgbPlane[i]
r, g, b := rgba.R, rgba.G, rgba.B
fmt.Printf("<div class='dot' style='background-color:#%02x%02x%02x'></div>", r, g, b)
i += 1
}
fmt.Println("</div>");
}
Big Buck Bunny is licensed under the Creative Commons Attribution 3.0 license.
(c) copyright 2008, Blender Foundation / www.bigbuckbunny.org