当前位置: 首页 > news >正文

宁波建设网站价格/怎么搭建一个网站

宁波建设网站价格,怎么搭建一个网站,外贸soho,武汉电商代运营公司排名我正在尝试创建一个可以缩放和拖动的SurfaceView。它实现了直接绘制到画布中的HTTP图像流我尝试了以下代码,它有点工作,但它给了我的边界问题。不知道为什么。任何帮助?全流:缩放图片:在第二张图片中,您可以…

我正在尝试创建一个可以缩放和拖动的SurfaceView。它实现了直接绘制到画布中的HTTP图像流

我尝试了以下代码,它有点工作,但它给了我的边界问题。不知道为什么。任何帮助?

全流:

48a9e2e87968f1e6a82bb04981ea8be0.png

缩放图片:

0bc46c93165220d1e5118e8ad6556fff.png

在第二张图片中,您可以看到不需要的多条绿线。

这是处理这个流的类:

import android.content.Context;

import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

import android.graphics.Canvas;

import android.graphics.Paint;

import android.graphics.Rect;

import android.graphics.RectF;

import android.graphics.drawable.BitmapDrawable;

import android.graphics.drawable.Drawable;

import android.util.AttributeSet;

import android.view.Display;

import android.view.MotionEvent;

import android.view.ScaleGestureDetector;

import android.view.SurfaceView;

import android.view.WindowManager;

/**

* Created by fil on 07/12/15.

*/

public class ZoomSurfaceView extends SurfaceView {

//These two constants specify the minimum and maximum zoom

private static float MIN_ZOOM = 1f;

private static float MAX_ZOOM = 5f;

private float scaleFactor = 1.f;

private ScaleGestureDetector detector;

//These constants specify the mode that we're in

private static int NONE = 0;

private static int DRAG = 1;

private static int ZOOM = 2;

private boolean dragged = false;

private float displayWidth;

private float displayHeight;

private int mode;

//These two variables keep track of the X and Y coordinate of the finger when it first

//touches the screen

private float startX = 0f;

private float startY = 0f;

//These two variables keep track of the amount we need to translate the canvas along the X

//and the Y coordinate

private float translateX = 0f;

private float translateY = 0f;

//These two variables keep track of the amount we translated the X and Y coordinates, the last time we

//panned.

private float previousTranslateX = 0f;

private float previousTranslateY = 0f;

private final Paint p = new Paint();

private void init(Context context){

detector = new ScaleGestureDetector(getContext(), new ScaleListener());

WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

Display display = wm.getDefaultDisplay();

displayWidth = display.getWidth();

displayHeight = display.getHeight();

}

public ZoomSurfaceView(Context context) {

super(context);

init(context);

}

public ZoomSurfaceView(Context context, AttributeSet attrs) {

super(context, attrs);

init(context);

}

public ZoomSurfaceView(Context context, AttributeSet attrs, int defStyleAttr) {

super(context, attrs, defStyleAttr);

init(context);

}

public ZoomSurfaceView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {

super(context, attrs, defStyleAttr, defStyleRes);

init(context);

}

public void resetZoom() {

}

public void drawBitmap(Canvas canvas, Bitmap b, Rect rect){

canvas.save();

//If translateX times -1 is lesser than zero, letfs set it to zero. This takes care of the left bound

if((translateX * -1) > (scaleFactor - 1) * displayWidth)

{

translateX = (1 - scaleFactor) * displayWidth;

}

if(translateY * -1 > (scaleFactor - 1) * displayHeight)

{

translateY = (1 - scaleFactor) * displayHeight;

}

//We need to divide by the scale factor here, otherwise we end up with excessive panning based on our zoom level

//because the translation amount also gets scaled according to how much we've zoomed into the canvas.

canvas.translate(translateX / scaleFactor, translateY / scaleFactor);

//We're going to scale the X and Y coordinates by the same amount

canvas.scale(scaleFactor, scaleFactor);

canvas.drawBitmap(b, null, rect, p);

/* The rest of your canvas-drawing code */

canvas.restore();

}

private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener

{

@Override

public boolean onScale(ScaleGestureDetector detector)

{

scaleFactor *= detector.getScaleFactor();

scaleFactor = Math.max(MIN_ZOOM, Math.min(scaleFactor, MAX_ZOOM));

return true;

}

}

@Override

public boolean onTouchEvent(MotionEvent event)

{

switch (event.getAction() & MotionEvent.ACTION_MASK)

{

case MotionEvent.ACTION_DOWN:

mode = DRAG;

//We assign the current X and Y coordinate of the finger to startX and startY minus the previously translated

//amount for each coordinates This works even when we are translating the first time because the initial

//values for these two variables is zero.

startX = event.getX() - previousTranslateX;

startY = event.getY() - previousTranslateY;

break;

case MotionEvent.ACTION_MOVE:

translateX = event.getX() - startX;

translateY = event.getY() - startY;

//We cannot use startX and startY directly because we have adjusted their values using the previous translation values.

//This is why we need to add those values to startX and startY so that we can get the actual coordinates of the finger.

double distance = Math.sqrt(Math.pow(event.getX() - (startX + previousTranslateX), 2) +

Math.pow(event.getY() - (startY + previousTranslateY), 2));

if(distance > 0)

{

dragged = true;

distance *= scaleFactor;

}

break;

case MotionEvent.ACTION_POINTER_DOWN:

break;

case MotionEvent.ACTION_UP:

mode = NONE;

dragged = false;

//All fingers went up, so letfs save the value of translateX and translateY into previousTranslateX and

//previousTranslate

previousTranslateX = translateX;

previousTranslateY = translateY;

break;

case MotionEvent.ACTION_POINTER_UP:

mode = DRAG;

//This is not strictly necessary; we save the value of translateX and translateY into previousTranslateX

//and previousTranslateY when the second finger goes up

previousTranslateX = translateX;

previousTranslateY = translateY;

break;

}

detector.onTouchEvent(event);

//We redraw the canvas only in the following cases:

//

// o The mode is ZOOM

// OR

// o The mode is DRAG and the scale factor is not equal to 1 (meaning we have zoomed) and dragged is

// set to true (meaning the finger has actually moved)

if ((mode == DRAG && scaleFactor != 1f && dragged) || mode == ZOOM)

{

invalidate();

}

return true;

}

}

用于将框架添加到曲面的代码如下所示:

if (!b.isRecycled()){

try {

Rect rect = new Rect(0, 0, frame.getWidth(), frame.getHeight());

Canvas canvas = frame.getHolder().lockCanvas();

synchronized (frame.getHolder()) {

if (!b.isRecycled()) {

frame.drawBitmap(canvas, b, rect);

b.recycle();

}

}

frame.getHolder().unlockCanvasAndPost(canvas);

} catch (java.lang.RuntimeException exc){

Dbg.d("ERROR", exc);

}

lastBitmap = b;

}

http://www.lbrq.cn/news/1055863.html

相关文章:

  • 网站建设课程内容/搜索引擎优化案例分析
  • 书店网站建设定位及目标/北京建公司网站价格
  • 襄阳网站制作/江苏营销型网站建设
  • 苏州外贸网站/搜索引擎营销的主要方法包括
  • 做网站流程、/百度搜索图片
  • 网页版传奇变态版/短视频seo厂家
  • 网站内容都是复制来的/百度官方营销推广平台加载中
  • 做网站的得花多钱/互联网广告优势
  • 做相册本哪个网站好用/品牌形象推广
  • 做滋补品销售有什么网站/有链接的网站
  • 河田镇建设局网站/网络营销师官网
  • 做网站推广的公司发展前景/湖南网站网络推广哪家奿
  • 做旅游网站需要的背景/国外搜索引擎大全不屏蔽
  • 深圳网站制作公司流程图/杭州今天查出多少阳性
  • 东莞市住房建设网站/网络推广需要花多少钱
  • 郑州哪个医院看妇科病最好的医院/茶叶seo网站推广与优化方案
  • iis7搭建asp网站/神童预言新冠2023结束
  • php做学校网站免费下载/潍坊网站关键词推广
  • wordpress admin 403/seo顾问是什么职业
  • 广州番禺网/青岛关键词优化平台
  • 广州网址大全/沈阳网站制作优化推广
  • 国外网站兼职做效果图/手机怎么自己制作网页
  • html5和css3制作个人网站源码/网络广告文案案例
  • iis 5 如何添加网站/seo工具网站
  • 人工智能/广告seo是什么意思
  • 上海网站制作 公司/免费企业黄页查询官网
  • 做网站本溪/公司网站制作公司
  • 济南正规网站建设公司哪家好/看网站搜索什么关键词
  • 青岛市住房和城乡建设局网站查询/网站推广是什么
  • 建立com网站/营销图片大全
  • [激光原理与应用-205]:光学器件 - LD与DFB的比较
  • 【SpringBoot】SpringBoot配置
  • 容器之王--部署Docker私有仓库harbor母盘步骤演练
  • 代码随想录day58图论8
  • nodejs 编程基础01-NPM包管理
  • YooAsset源码阅读-Downloader篇