Rotating a bitmap 90 degrees

前端 未结 9 1730
粉色の甜心
粉色の甜心 2021-02-04 05:49

I have a one 64-bit integer, which I need to rotate 90 degrees in 8 x 8 area (preferably with straight bit-manipulation). I cannot figure out any handy algorith

9条回答
  •  生来不讨喜
    2021-02-04 06:46

    If an if-powered loop is acceptable, the formula for bits is simple enough:

    8>>Column - Row - 1
    

    Column and Row are 0-indexed.

    This gives you this mapping:

     7 15 23 31 39 47 55 63
     6 14 22 ...
     5 ...
     4 ...
     3 ...
     2 ...
     1 ...
     0  8 16 24 32 40 48 54 
    

提交回复
热议问题