有用过F133 melis系统的g2d吗?
-
各位有用过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,不知道哪位老板用过,请教一下。 -
rect 的size 需要比dst_image 的小。你有没高反啊?
Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号