计算Facebook封面偏移y [英] Calculate the facebook cover offset y

查看:143
本文介绍了计算Facebook封面偏移y的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Facebook SDK获取用户封面照片。我有通往img和偏移量y的路径。

I'm getting the user cover photo using Facebook SDK. I have the path to the img and the offset y.

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

我放置图像的div有300px高度;右边的背景位置是 center -146px; 。当我有300和19岁时,如何计算顶值

The div where i put the image have 300px height; and right background position is center -146px;. How to calculate the top value when I have 300 and 19 ?

推荐答案

offset_y 是裁剪图像的上区域和下区域之间的一部分空间。

offset_y is a proportion of space between upper area and lower area of cropped image.

因此,实际像素偏移应该是这样的:

So, actual pixel offset should be like this:

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

这篇关于计算Facebook封面偏移y的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆