gpt4 book ai didi

jquery - jcrop - 中心的默认裁剪选择

转载 作者:行者123 更新时间:2023-12-01 01:23:58 25 4
gpt4 key购买 nike

我在 ASP.NET C# 应用程序中使用 JCrop 来裁剪图像。默认情况下,我希望将裁剪选择区域设置在图像的中心,这是我当前的代码,但问题是,它总是从 0,0 开始选择。

            $('#img_crop').Jcrop({    //img_crop is the ID of image control
onChange: updatePreview, // will display the selected img on change.
onSelect: updatePreview, // will display the selected img Img_preview
bgColor: 'black',
bgOpacity: .6,
//setSelect: [100, 100, 240, 240],
setSelect: [ ($('#img_crop').attr('width') / 2) - 70,
($('#img_crop').attr('height') / 2) - 70,
($('#img_crop').attr('width') / 2) + 70,
($('#img_crop').attr('height') / 2) + 70
],
onSelect: storeCoords, // will tell the coordinates
aspectRatio: 1

}

最佳答案

属性“宽度”和“高度”可能未设置。我宁愿使用 $('#img_crop').width() 和 $('#img_crop').height() 来代替,看看是否有效。

关于jquery - jcrop - 中心的默认裁剪选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20744473/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com