screenshot in Android - 4

MagicProgram發表於2012-06-15
Everyone knows that the android device supports free rotation, however, my application just copes the framebuffer and builds jpeg files with solid resolution. The problem is how to transfer the framebuffer matrix into the correct matrix, during the rotation.

Let me give a sketch map for explanation as bellows.

     (Aij)                       (Bmn)
0 1 2 3 4                     a 5 0
5 6 7 8 9     ====>    b 6 1  
a b c d e                     c 7 2
                                    d 8 3
                                    e 9 4

So we should realign the jpeg matrix Bmn from the original Aij and the key problem is getting the relationship between mn and ij. (which (m, n), (i, j) is the coordinate)

if rotate the screen 90 degree in the time order, then the relationship will be
{i = height - 1 - n; j = m}.

if rotate the screen 180 degree in the time order, then it will be
{i = height - 1 - m; j = width - 1 - n}.

if rotate the screen 270 degree in the time order, then it will be
{i = n; j = width - 1 - m}.

According these rules, you can get the correct jpeg files even rotating devices.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25432352/viewspace-732929/,如需轉載,請註明出處,否則將追究法律責任。

相關文章