导航

    全志在线开发者论坛

    • 注册
    • 登录
    • 搜索
    • 版块
    • 话题
    • 在线文档
    • 社区主页

    有用过F133 melis系统的g2d吗?

    MR Series
    2
    2
    1308
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • T
      tianj03 LV 2 最后由 tianj03 编辑

      各位有用过F133 melis系统的g2d功能吗?我需要一个图片缩放的功能,软件缩放太慢,想用g2d功能加速一下。但是用不了。我的代码如下:
      static int g2d_img_scale(char* src, int src_w, int src_h, char* dst, int dst_w, int dst_h)
      {
      int g2d_fd = open("/dev/g2d", O_RDWR);
      if (g2d_fd < 0)
      {
      eLIBs_printf("g2d_img_effect1, open g2d failed, g2d_fd: %d\n", g2d_fd);
      return -1;
      }
      eLIBs_printf("g2d_img_effect1, open g2d success, g2d_fd: %d\n", g2d_fd);

      g2d_stretchblt *pstStchBlt = (g2d_stretchblt*)eLIBs_malloc(sizeof(*pstStchBlt));
      if (!pstStchBlt)
      {
          eLIBs_printf("g2d_img_effect1, malloc pstStchBlt failed, g2d_fd: %d\n", g2d_fd);
          close(g2d_fd);
          return -1;
      }
      eLIBs_memset(pstStchBlt, 0, sizeof(*pstStchBlt));
      
      pstStchBlt->flag = G2D_BLT_NONE;
      pstStchBlt->color = 0;
      pstStchBlt->alpha = 0;
      pstStchBlt->src_image.addr[0] = src;
      pstStchBlt->src_image.format = G2D_FORMAT_ARGB8888;
      pstStchBlt->src_image.w = src_w;
      pstStchBlt->src_image.h = src_h;
      pstStchBlt->src_image.pixel_seq = G2D_SEQ_NORMAL;
      pstStchBlt->src_rect.x = 0;
      pstStchBlt->src_rect.y = 0;
      pstStchBlt->src_rect.w = src_w;
      pstStchBlt->src_rect.h = src_h;
      
      pstStchBlt->dst_image.addr[0] = dst;
      pstStchBlt->dst_image.format = G2D_FORMAT_ARGB8888;
      pstStchBlt->dst_image.w = dst_w;
      pstStchBlt->dst_image.h = dst_h;
      pstStchBlt->dst_image.pixel_seq = G2D_SEQ_NORMAL;
      pstStchBlt->dst_rect.x = 0;
      pstStchBlt->dst_rect.y = 0;
      pstStchBlt->dst_rect.w = dst_w;
      pstStchBlt->dst_rect.h = dst_h;
      
      int iRet = ioctl(g2d_fd, G2D_CMD_STRETCHBLT, pstStchBlt);
      if (iRet != 0) {
          eLIBs_printf("do G2D_CMD_STRETCHBLT failed!iRet: %d\n", iRet);
          close(g2d_fd);
          eLIBs_free(pstStchBlt);
          return -1;
      }
      close(g2d_fd);
      eLIBs_free(pstStchBlt);
      return 0;
      

      }
      就是在ioctl(g2d_fd, G2D_CMD_STRETCHBLT, pstStchBlt);返回-1,不知道哪位老板用过,请教一下。

      1 条回复 最后回复 回复 引用 分享 0
      • B
        Bruce_Gan LV 3 最后由 编辑

        rect 的size 需要比dst_image 的小。你有没高反啊?

        1 条回复 最后回复 回复 引用 分享 0
        • 1 / 1
        • First post
          Last post

        Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

        行为准则 | 用户协议 | 隐私权政策