我正在尝试将大型的高分辨率(3225x4800)图片从URL加载到一家报纸公司的幻灯片中。我要加载的图像是此高分辨率图像。
String url = "http://www.businessweekmindanao.com/content/wp-content/uploads/2015/10/fitness-and-wellness-poster-final.jpg";
Glide.with(getActivity()).load(url).asBitmap().into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
imageView.setImageBitmap(resource);
}
});
Run Code Online (Sandbox Code Playgroud)
我从此处提供的解决方案中使用Mike Ortiz的TouchImageView:从URL加载资源时,https : //github.com/MikeOrtiz/TouchImageView/issues/135。但它似乎仅适用于小分辨率图像,并且无法加载高质量图像。
我从stackoverflow中尝试了另一种解决方案:Android:未显示带有UIL和TouchImageView的ImageView,它试图修改Mike的库的onMeasure()方法。它适用于:
Glide.with(getActivity()).load(url)
.into(imageViewPreview);
Run Code Online (Sandbox Code Playgroud)
问题在于它以非常低的分辨率加载图像。
有没有办法加载像Glide和TouchImageView这样的高分辨率图像:7480x3740?我怎么做?
我正在制作非常简单的应用程序。它需要显示一个包含广义世界地图的 SVG。通过单击城市名称(svg 矩形),我需要显示与该城市对应的另一个 SVG。此外,所有 SVG 都必须支持缩放和平移。
我设法让 SVG 支持缩放和平移,效果很好。为此,我使用svg-android库来渲染SVG,并使用定制的TouchImageView进行平移、缩放和捕获缩放和触摸事件。但是,在 Android 中的 SVG 上制作可点击区域似乎是不可能的。
我尝试了蛮力,在每次用户交互(触摸或缩放)和每次点击 SVG 时重新计算我感兴趣区域的位置,以检查我的区域(矩形列表)是否包含该点,并执行相应的操作。
这不起作用,因为我无法理解计算规则MotionEvent#getX/Y和类似方法。也许我可以为固定 SVG 实现这一点,但对于可缩放,我真的不能。
任何提示?这在Android中甚至可能吗?
我正在使用Googles Mobile Vision API识别静态位图中的文本(数字).现在我想放大到找到号码的地方.
这就是我扫描Bitmap并获取x和y坐标的方法
Point [] p = textBlock.getCornerPoints();
public void Test(Bitmap bitmap) {
Context context = getApplicationContext();
TextRecognizer ocrFrame = new TextRecognizer.Builder(context).build();
Frame frame = new Frame.Builder().setBitmap(bitmap).build();
ByteBuffer byteBuffer = frame.getGrayscaleImageData();
if (ocrFrame.isOperational()) {
Log.e(TAG, "Textrecognizer is operational");
}
SparseArray<TextBlock> textBlocks = ocrFrame.detect(frame);
for (int i = 0; i < textBlocks.size(); i++) {
TextBlock textBlock = textBlocks.get(textBlocks.keyAt(i));
String value = textBlock.getValue();
Point[] p = textBlock.getCornerPoints();
Log.e(TAG, "something is happening");
}
}
Run Code Online (Sandbox Code Playgroud)
此外,我使用TouchImageView显示位图.现在我用我获得的坐标调用setZoom方法,如下所示:
touchImageView.setZoom(1F,210F,748F,ImageView.ScaleType.CENTER);
但它缩放到错误的地方,我不知道为什么.有人可以给我一些提示吗?
(https://github.com/MikeOrtiz/TouchImageView/blob/master/src/com/ortiz/touch/TouchImageView.java)
编辑:好的,我发现缩放类型做了我没有得到的东西.我想这里的问题是setZoom.我必须将位图的坐标转换为Touchimageview的坐标. …
我使用Universal Image Loader库加载一组图像和TouchImageView以允许缩放.我决定用毕加索取代Universal Image Loader.一切都很好,除了现在图像缩放到比图像稍大的帧.
@Override
public Object instantiateItem(ViewGroup view, int position) {
View imageLayout = inflater.inflate(R.layout.item_pager_image, view, false);
assert imageLayout != null;
TouchImageView imageView = (TouchImageView) imageLayout.findViewById(R.id.image);
final ProgressBar spinner = (ProgressBar) imageLayout.findViewById(R.id.loading);
spinner.setVisibility(View.INVISIBLE);
Picasso.with(getApplicationContext()).setIndicatorsEnabled(false);
Picasso.with(getApplicationContext()).load(images[position]).into(imageView,new Callback() {
@Override
public void onSuccess() {
spinner.setVisibility(View.GONE);
}
@Override
public void onError() {
}
});
view.addView(imageLayout, 0);
return imageLayout;
Run Code Online (Sandbox Code Playgroud)
为此,我几个小时就一直在挣扎.这是TouchImageView与Picasso有关的问题吗?任何帮助都会很明显.谢谢.
我在ScrollView中有一个TouchImageView但是当我缩放imageview并尝试向上/向下滑动时,响应来自ScrollView.当我触摸TouchImageView时,有没有办法停止ScrollView
我制作了一个应用程序,它从 url 下载图像(使用Universal Image Loader库)并将该图像显示在TouchImageView. 我使用触摸图像视图来实现捏缩放功能。我按照本教程学习了如何使用 TouchImageView。
问题是,每当我放大由通用图像加载器下载的图像并将另一个图像加载到 TouchImageView 中时,新图像就会被拉伸和扭曲。当通过缩小先前缩放的图像恢复到原始大小,然后加载新图像时,这个问题就得到了解决。
因此可以通过缩小加载的图像然后加载新图像来解决该问题。但我不知道如何重置缩放,并且库没有提供这方面的功能。
我尝试使用最新版本TouchImageView(其中包括重置图像功能),但较新版本与 不兼容,UIL而且该教程似乎仅使用原始库中的部分代码(尽管其工作正常)。
有谁知道如何重置放大吗TouchImageView?
**强文字**代码:
package com.hpubts50.hpubustracker;
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import android.widget.ImageView;
public class TouchImageView extends ImageView {
Matrix matrix ;
// We can be in one of these 3 states
static final int NONE = 0;
static final int DRAG = 1; …Run Code Online (Sandbox Code Playgroud) 我知道onLongTouchListener不存在,所以我正在尝试制作自己的版本,因为我真的需要触摸坐标,所以不能使用onLongClickListener。我的代码如下:
touchImageView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, final MotionEvent motionEvent) {
CountDownTimer counter = new CountDownTimer(500, 1) {
public void onTick(long millisUntilFinished) {
System.out.println("REMAINING: "+(millisUntilFinished));
}
public void onFinish() {
System.out.println("IT'S OVER");
}
};
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN){
counter.start();
} else if( motionEvent.getAction() == MotionEvent.ACTION_UP){
counter.cancel();
}
return true;
}
});
Run Code Online (Sandbox Code Playgroud)
问题是:当我将手指放在屏幕上时,计数器开始计数,但是按我的预期抬起手指并没有取消计数:
else if( motionEvent.getAction() == MotionEvent.ACTION_UP){
counter.cancel();
}
Run Code Online (Sandbox Code Playgroud)
你们能帮我吗?
编辑:
遵循评论和答案后,它现在可以工作:
final CountDownTimer counter;
counter = new CountDownTimer(500,1) {
@Override
public void onTick(long l) {
System.out.println("REMAINING "+l); …Run Code Online (Sandbox Code Playgroud) android ×7
image ×1
java ×1
motionevent ×1
picasso ×1
scrollview ×1
svg ×1
svg-android ×1
zoom ×1