JCROP-中心的默认裁剪选择



我正在 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
            }
属性

"width"和"height"可能未设置。我宁愿使用 $('#img_crop').width() 和 $('#img_crop').height() 来代替,看看它是否有效。

最新更新