您当前的位置: 首页 >  矩阵

柳鲲鹏

暂无认证

  • 0浏览

    0关注

    4642博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

全网首发:以字型为例,一维表示的二维数组矩阵,以易理解的方式旋转90、-90

柳鲲鹏 发布时间:2020-12-07 18:24:15 ,浏览量:0

  原文参考:

https://quantum6.blog.csdn.net/article/details/110794038

  在使用过程中,吾发现旋转代码很难理解。如果原来数据有特殊要求,这样是有问题的。于是经过一番实验(列出了一个数组,然后手工旋转,对照算法),找到了新的公式:

static void rotate_90(FT_Bitmap* pBmp)
{
    int w = pBmp->width;
    int h = pBmp->rows;
    int i=0;
    char* pRotated;
 
    int size;
    int offset=0;
 
    size = w * h;
    pRotated = (char*)malloc(size);
    memcpy(pRotated, pBmp->buffer, size);

    for (int y=0; ybuffer[(h-y-1)*w+x];
        }
    }

    dumpBuffer(pRotated, h, w);
}
 
static void rotate_270(FT_Bitmap* pBmp)
{
    int w = pBmp->width;
    int h = pBmp->rows;
    int i=0;
    char* pRotated;
 
    int size;
    int offset=0;
 
    size = w * h;
    pRotated = (char*)malloc(size);
    memcpy(pRotated, pBmp->buffer, size);

    for (int y=0; ybuffer[y*w+x];
        }
    }

    dumpBuffer(pRotated, h, w);
}

 

关注
打赏
1665724893
查看更多评论
立即登录/注册

微信扫码登录

0.2960s