送给我喜欢的人系列_无法点击的拒绝

无法点击的拒绝

如果侵权请联系,会进行删除。
练手刚刚好。
在这里插入图片描述
在这里插入图片描述

// An highlighted block
<h1 style="position:absolute; left:280px; top:155px; width:auto; height:210px;">你喜欢我吗?</h1>
<div id="By" style="position:absolute; left:285px; top:235px;">
  <input type="button" value=" 是的! " onclick="f1()">
</div>
<div id="Bn" style="position:absolute; left:360px; top:235px;">
  <input type="button" value=" 想要拒绝的话就点我! " onmouseover="f()" onclick="f2()">
</div>

<script type="text/javascript">
  function f1() {
    alert("我猜也是,毕竟我这么优秀!!!")
  }
  var flag = 1;

  function f() {
    var Bn = document.getElementById('Bn');
    var aWidth = document.body.clientWidth || document.documentElement.clientWidth;
    var aHeight = document.body.clientHeight || document.documentElement.clientHeight;
    var sJs1 = Math.floor(Math.random() * aHeight);
    var sJs2 = Math.floor(Math.random() * aWidth);
    if (flag == 1) {
      Bn.style.top = sJs1 + 'px';
      Bn.style.left = sJs2 + 'px';
      flag = 2;

    } else if (flag == 2) {
      Bn.style.top = sJs1 + 'px';
      Bn.style.left = sJs2 + 'px';
      flag = 3;
    } else if (flag == 3) {
      Bn.style.top = 235 + 'px';
      Bn.style.left = 286 + 'px';
      flag = 4;
    } else if (flag == 4) {
      Bn.style.top = 235 + 'px';
      Bn.style.left = 360 + 'px';
      flag = 1;
    }
  }

  function f2() {
    alert('这不是你的真心话!');
  }
</script>
### YUV420 转 Bitmap 并调用 HI_MPI_RGN_SetBitMap 的实现 在嵌入式视频处理系统中,YUV420 是一种常见的图像格式,通常用于从解码器或摄像头获取的原始数据。为了将这些数据叠加到视频输出上(如通过 `HI_MPI_RGN_SetBitMap` 接口),需要将其转换为 ARGB8888 格式的 Bitmap 图像。 #### 数据结构定义 在使用 `HI_MPI_RGN_SetBitMap` 时,需要准备 `BITMAP_S` 和 `OSD_REGION_INFO_S` 结构体。其中 `BITMAP_S` 包含图像宽度、高度和像素数据指针,而 `OSD_REGION_INFO_S` 描述了区域的位置和大小: ```c typedef struct { PIXEL_FORMAT_E enPixelFormat; // 像素格式,例如 PIXEL_FORMAT_ARGB_8888 RK_U32 u32Width; RK_U32 u32Height; RK_U8 *pData; // 图像数据指针 } BITMAP_S; typedef struct { RK_U32 enRegionId; RK_U32 u32PosX; RK_U32 u32PosY; RK_U32 u32Width; RK_U32 u32Height; RK_U8 u8Enable; RK_U8 u8Inverse; } OSD_REGION_INFO_S; ``` #### YUV420 转换为 ARGB8888 的方法 YUV420 格式由三个平面组成:Y、U、V,其中 U 和 V 的分辨率是 Y 的四分之一。转换函数需遍历每个 Y 值,并根据其对应的 U 和 V 值计算 RGB 值,再填充至 ARGB8888 格式中: ```c void yuv420_to_argb8888(RK_U8 *y_plane, RK_U8 *u_plane, RK_U8 *v_plane, RK_U8 *argb_data, int width, int height) { int y_size = width * height; int uv_size = (width / 2) * (height / 2); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int y_index = y * width + x; int uv_index = (y / 2) * (width / 2) + (x / 2); int y_val = y_plane[y_index]; int u_val = u_plane[uv_index]; int v_val = v_plane[uv_index]; // YUV to RGB 转换公式 int r = y_val + 1.402 * (v_val - 128); int g = y_val - 0.344 * (u_val - 128) - 0.714 * (v_val - 128); int b = y_val + 1.772 * (u_val - 128); // Clamp 到 [0, 255] r = (r < 0) ? 0 : ((r > 255) ? 255 : r); g = (g < 0) ? 0 : ((g > 255) ? 255 : g); b = (b < 0) ? 0 : ((b > 255) ? 255 : b); int argb_index = y_index * 4; argb_data[argb_index] = a; // Alpha 通道设为 255(不透明) argb_data[argb_index + 1] = r; argb_data[argb_index + 2] = g; argb_data[argb_index + 3] = b; } } } ``` #### 分配内存并初始化 BITMAP_S 在完成 YUV420 到 ARGB8888 的转换后,需将数据填充至 `BITMAP_S` 结构体,并调用 `HI_MPI_RGN_SetBitMap` 设置位图信息: ```c int osd_w = 720; int osd_h = 1280; BITMAP_S BitMap; BitMap.enPixelFormat = PIXEL_FORMAT_ARGB_8888; BitMap.u32Width = osd_w; BitMap.u32Height = osd_h; BitMap.pData = malloc(BitMap.u32Width * 4 * BitMap.u32Height); // 每个像素占 4 字节 // 假设 y_plane, u_plane, v_plane 已正确读取 yuv420_to_argb8888(y_plane, u_plane, v_plane, BitMap.pData, osd_w, osd_h); OSD_REGION_INFO_S RngInfo; RngInfo.enRegionId = REGION_ID_0; RngInfo.u32PosX = 0; RngInfo.u32PosY = 0; RngInfo.u32Width = osd_w; RngInfo.u32Height = osd_h; RngInfo.u8Enable = 1; RngInfo.u8Inverse = 0; RK_MPI_RGA_RGN_SetBitMap(0, &RngInfo, &BitMap); ``` #### 注意事项与优化建议 - **内存管理**:确保每次分配的 `pData` 在使用完毕后释放,避免内存泄漏。 - **性能优化**:若频繁进行图像格式转换,可考虑使用 SIMD 指令集或 GPU 加速以提高效率。 - **兼容性处理**:不同设备可能对 YUV 数据排列方式存在差异,应适配不同的色度采样布局。 - **动态范围转换**:部分芯片支持 HDR 动态范围转换,需设置 `bVgsHdrSupport=1` 以启用此功能[^3]。 ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值