使用搜寻栏将图像缩放到X,Y坐标

问题描述

我想使用搜索栏将图像缩放到特定的X,Y坐标。我正在从服务器获取X,Y坐标,并且想要放大和缩小。缩放X,Y坐标应位于中心。我正在尝试从Github编辑zoomage库。该库支持捏缩放。

下面是我的搜索栏监听器:

mySeekBar?.setOnSeekBarChangeListener(object :
                SeekBar.OnSeekBarChangeListener {
            override fun onProgressChanged(seek: SeekBar,progress: Int,fromUser: Boolean) {
                // write custom code for progress is changed
                var scaleFactor = ((progress / 100.0f) + 1)
                before_after_gif.startScale(scaleFactor)
                before_after_gif.scaleImage(162f,145f)
                if (progress == 0)
                    before_after_gif.reset(true)


            }

            override fun onStartTrackingTouch(seek: SeekBar) {
                // write custom code for progress is started

            }

            override fun onStopTrackingTouch(seek: SeekBar) {
                // write custom code for progress is stopped

            }
        })



public  void startScale(float scaleFactor){
        startScale = matrixValues[Matrix.MSCALE_X];
        //calculate value we should scale by,ultimately the scale will be startScale*scaleFactor
        scaleBy = (startScale * scaleFactor) / matrixValues[Matrix.MSCALE_X];

        //what the scaling should end up at after the transformation
        final float projectedScale = scaleBy * matrixValues[Matrix.MSCALE_X];

        //clamp to the min/max if it's going over
        if (projectedScale < calculatedMinScale) {
            scaleBy = calculatedMinScale / matrixValues[Matrix.MSCALE_X];
        } else if (projectedScale > calculatedMaxScale) {
            scaleBy = calculatedMaxScale / matrixValues[Matrix.MSCALE_X];
        }
    }

 public void  scaleImage(float x,float y){
        if (getScaleType() != ScaleType.MATRIX) {
            super.setScaleType(ScaleType.MATRIX);
        }

        if (startValues == null) {
            setStartValues();
        }

        //get the current state of the image matrix,its values,and the bounds of the drawn bitmap
        matrix.set(getImageMatrix());
        matrix.getValues(matrixValues);
        updateBounds(matrixValues);
        if (matrixValues[Matrix.MSCALE_X] != startValues[Matrix.MSCALE_X]) {
            reset();
        } else {
            Matrix zoomMatrix = new Matrix(matrix);
            zoomMatrix.postScale(doubleTapToZoomScaleFactor,doubleTapToZoomScaleFactor,x,y);
            animateScaleAndTranslationToMatrix(zoomMatrix,RESET_DURATION);
        }
    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...