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

柳鲲鹏

暂无认证

  • 0浏览

    0关注

    4642博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

全网首发:把一个bit数组矩阵旋转90度

柳鲲鹏 发布时间:2020-12-08 08:55:43 ,浏览量:0

接上文。

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

将数组旋转90度:

static char* rotate_90(char* pBuffer, int w, int h, int pitch)
{
    int i=0;
    char* pRotated;

    int size;
    int offset=0;

    if (w < h)
    {
        w = h;
    }
    else if (w > h)
    {
        w = h;
    }


    size = h * pitch;
    pRotated = (char*)malloc(size);
    memset(pRotated, 0, size);

    int startPos = (h - 1) * pitch*8;
    i = 0;
    for (int x = 0; x < w; x++)
    {
        int offset = startPos;
        for (int y = h - 1; y >= 0; y--)
        {
            int dstPos = i/w*pitch*8+i%w;
            int dstPosByte  = (dstPos)/8;
            int dstPosBit   = (dstPos)%8;

            int srcPos      = (offset + x);
            int srcPosByte  = srcPos / 8;
            int srcPosBit   = srcPos % 8;
            int srcBitValue = (pBuffer[srcPosByte] & (0x01             
关注
打赏
1665724893
查看更多评论
0.2940s