YUV format online tool

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
To decode a YUV 420 888 format image to a Dart Image, you can use the following steps: 1. Convert the YUV 420 888 data to RGB data. 2. Create a new Image object with the RGB data. Here's an example code snippet that demonstrates how to do this: ```dart import 'dart:typed_data'; import 'package:image/image.dart'; // Assume that `yuvData`, `uData`, and `vData` are Uint8List objects containing the YUV 420 888 data. // Calculate the size of the image. final width = (yuvData.length * 3 / 2).sqrt(); final height = width * 3 / 4; // Convert the YUV data to RGB data. final rgbData = Uint8List(width.toInt() * height.toInt() * 3); int p = 0; for (int j = 0; j < height.toInt(); j++) { final yp = j * width.toInt(); final up = (j >> 1) * (width.toInt() >> 1); final vp = up; for (int i = 0; i < width.toInt(); i++) { final y = yuvData[yp + i] - 16; final u = uData[up + (i >> 1)] - 128; final v = vData[vp + (i >> 1)] - 128; rgbData[p++] = (y + 1.402 * v).toInt().clamp(0, 255); rgbData[p++] = (y - 0.34414 * u - 0.71414 * v).toInt().clamp(0, 255); rgbData[p++] = (y + 1.772 * u).toInt().clamp(0, 255); } } // Create a new Image object with the RGB data. final image = Image.fromBytes(width.toInt(), height.toInt(), rgbData); ``` Note that this code assumes that the YUV 420 888 data is in planar format, where the Y, U, and V components are stored in separate arrays. If your YUV 420 888 data is in interleaved format, where the U and V components are interleaved with the Y component, you will need to modify the code accordingly.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值