2

Facebook SDK を使用してユーザーのカバー写真を取得しています。img へのパスとオフセット y があります。

  "source": "http://a5.sphotos.ak.fbcdn.net/hphotos-ak-ash3/526114_459046674110601_992101492_n.jpg",
  "offset_y": 19

画像を配置する div の高さは 300px です。そして右背景位置はcenter -146px;です。top value300 と 19 があるときの計算方法は?

4

1 に答える 1

0

offset_yトリミングされた画像の上部領域と下部領域の間のスペースの比率です。

したがって、実際のピクセルオフセットは次のようになります。

y = (offset_y / 100) * (upperArea_of_cropImage.height + lowerArea_of_cropImage.height)

編集:

// where y is the actual pixels from the upper left corner of the real image to
// upper left corner of the cropped image

        -- ================================  --
    y {   ||                              ||    } a
        --||..............................|| --
          ||                              ||
          ||                              ||
          ||            Cover             ||
          ||                              ||
          ||..............................|| --
          ||                              ||    } b
          ||                              ||   |
           ================================  --

     offset_y that Facebook send to you actually was a/b not y
于 2012-08-30T12:47:04.163 に答える