com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView Java Examples
The following examples show how to use
com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PhotoViewHolder.java From Camera-Roll-Android-App with Apache License 2.0 | 6 votes |
private void scaleDown(final ItemActivity.Callback callback) { final SubsamplingScaleImageView imageView = itemView.findViewById(R.id.subsampling); if (imageView != null) { try { imageView.animateScale(0.0f) .withDuration(300) .withOnAnimationEventListener( new SubsamplingScaleImageView.DefaultOnAnimationEventListener() { @Override public void onComplete() { super.onComplete(); swapView(true); callback.done(); //imageView.recycle(); } }) .start(); } catch (NullPointerException e) { swapView(true); callback.done(); //imageView.recycle(); } } }
Example #2
Source File: ImageAdapter.java From FrescoUtils with Apache License 2.0 | 6 votes |
private View ShowBigImg(final ViewGroup container, final int position) { RelativeLayout layout = (RelativeLayout) LayoutInflater.from(context).inflate(R.layout.big_img_layout, container, false); final SubsamplingScaleImageView imageView = (SubsamplingScaleImageView) layout.findViewById(R.id.image_item); final String imageUri = images.get(position).getUri(); FrescoHelper.loadBigImage(context, imageView, imageUri, R.mipmap.ic_launcher); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(context, "点击可以退出", Toast.LENGTH_SHORT).show(); } }); container.addView(layout); return layout; }
Example #3
Source File: ImageViewerLayout.java From hipda with GNU General Public License v2.0 | 6 votes |
public ImageViewerLayout(Activity activity, ContentImg contentImg) { super(activity); mRequestManager = Glide.with(activity); mUrl = contentImg.getContent(); mContentImg = contentImg; mImageView = new ImageView(getContext()); addView(mImageView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mScaleImageView = new SubsamplingScaleImageView(getContext()); addView(mScaleImageView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mProgressBar = new DownloadProgressBar(getContext()); int progressbarWidth = Utils.dpToPx(45); RelativeLayout.LayoutParams pbLayoutParams = new RelativeLayout.LayoutParams(progressbarWidth, progressbarWidth); pbLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); mProgressBar.setCancelable(false); mProgressBar.setFinishIcon(ContextCompat.getDrawable(getContext(), R.drawable.ic_action_play)); mProgressBar.setVisibility(GONE); addView(mProgressBar, pbLayoutParams); }
Example #4
Source File: ItemActivity.java From Camera-Roll-Android-App with Apache License 2.0 | 6 votes |
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (albumItem instanceof Photo) { View itemView = viewPager.findViewWithTag(albumItem.getPath()); if (itemView != null) { View view = itemView.findViewById(R.id.subsampling); if (view instanceof SubsamplingScaleImageView) { SubsamplingScaleImageView imageView = (SubsamplingScaleImageView) view; ImageViewState state = imageView.getState(); if (state != null) { outState.putSerializable(IMAGE_VIEW_SAVED_STATE, state); } } } } //outState.putParcelable(ALBUM, album); outState.putParcelable(ALBUM_ITEM, albumItem); outState.putBoolean(WAS_SYSTEM_UI_HIDDEN, !systemUiVisible); outState.putBoolean(INFO_DIALOG_SHOWN, infoDialog != null); }
Example #5
Source File: MapViewFragment.java From IndiaSatelliteWeather with GNU General Public License v2.0 | 6 votes |
@UiThread void renderImage() { final String mapFileName = AppConstants.getMapType(pageNumber, mapType.value); String imageFile = StorageUtils.getAppSpecificFolder() + File.separator + mapFileName + ".jpg"; if (!StorageUtils.fileExists(imageFile)) { Log.e("File not exists: " + pageNumber); noImageBanner.setVisibility(View.VISIBLE); map_updated_time.setVisibility(View.GONE); activityContext.initiateDownload(); return; } map_updated_time.setVisibility(View.VISIBLE); if (mapViewState != null) { touchImage.setImageFile(imageFile, mapViewState); } else { touchImage.setScaleAndCenter(2f, touchImage.getCenter()); touchImage.setImageFile(imageFile); } touchImage.setMaxScale(7f); touchImage.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_CROP); Log.d("Map refreshed"); updateLastModifiedTime(mapFileName); }
Example #6
Source File: PhotoViewFragment.java From AndroidUiKit with Apache License 2.0 | 6 votes |
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mImageView = view.findViewById(R.id.siv_raw_imageview); mImageView.setDismissListener(this); mImageView.setDoubleTapZoomScale(2.0f); mImageView.setMaxScale(3.0f); mImageView.setOnImageEventListener(new SubsamplingScaleImageView.DefaultOnImageEventListener() { @Override public void onImageLoaded() { super.onImageLoaded(); mProgressBar.setVisibility(View.GONE); } @Override public void onImageLoadError(Exception e) { super.onImageLoadError(e); mProgressBar.setVisibility(View.GONE); } }); mProgressBar = view.findViewById(R.id.progressbar); loadThumb(); loadImageView(); }
Example #7
Source File: ViewPagerFragment.java From subsampling-scale-image-view with Apache License 2.0 | 6 votes |
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(layout.view_pager_page, container, false); if (savedInstanceState != null) { if (asset == null && savedInstanceState.containsKey(BUNDLE_ASSET)) { asset = savedInstanceState.getString(BUNDLE_ASSET); } } if (asset != null) { SubsamplingScaleImageView imageView = rootView.findViewById(id.imageView); imageView.setImage(ImageSource.asset(asset)); } return rootView; }
Example #8
Source File: BigImageView.java From ImageLoader with Apache License 2.0 | 6 votes |
public void setInitScaleType(int initScaleType) { mInitScaleType = initScaleType; switch (initScaleType) { case INIT_SCALE_TYPE_CENTER_CROP: mImageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_CROP); break; case INIT_SCALE_TYPE_AUTO: mImageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CUSTOM); break; case INIT_SCALE_TYPE_CENTER_INSIDE: default: mImageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_INSIDE); break; } if (mDisplayOptimizeListener != null) { mDisplayOptimizeListener.setInitScaleType(initScaleType); } }
Example #9
Source File: BitmapUtils.java From leafpicrevived with GNU General Public License v3.0 | 6 votes |
public static int getOrientation(Uri uri, Context ctx) { try (InputStream in = ctx.getContentResolver().openInputStream(uri)) { if (in == null) { return 0; } ExifInterface exif = new ExifInterface(in); int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1); switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_180: return SubsamplingScaleImageView.ORIENTATION_180; case ExifInterface.ORIENTATION_ROTATE_90: return SubsamplingScaleImageView.ORIENTATION_90; case ExifInterface.ORIENTATION_ROTATE_270: return SubsamplingScaleImageView.ORIENTATION_270; default: return SubsamplingScaleImageView.ORIENTATION_0; } } catch (IOException e) { return 0; } }
Example #10
Source File: ImageDisplayLargeFragment.java From subsampling-scale-image-view with Apache License 2.0 | 5 votes |
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(layout.imagedisplay_large_fragment, container, false); final ImageDisplayActivity activity = (ImageDisplayActivity)getActivity(); if (activity != null) { rootView.findViewById(id.next).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { activity.next(); } }); } SubsamplingScaleImageView imageView = rootView.findViewById(id.imageView); imageView.setImage(ImageSource.asset("card.png")); return rootView; }
Example #11
Source File: ImageFragment.java From leafpicrevived with GNU General Public License v3.0 | 5 votes |
/** * Rotate the currently displaying media image. * * @param rotationInDegrees The rotation in degrees */ public void rotatePicture(int rotationInDegrees) { if (rotationInDegrees == -90 && imageView.getOrientation() == 0) { imageView.setOrientation(SubsamplingScaleImageView.ORIENTATION_270); } else { imageView.setOrientation(Math.abs(imageView.getOrientation() + rotationInDegrees) % 360); } }
Example #12
Source File: SkiaPooledImageRegionDecoder.java From subsampling-scale-image-view with Apache License 2.0 | 5 votes |
@SuppressWarnings({"WeakerAccess", "SameParameterValue"}) public SkiaPooledImageRegionDecoder(@Nullable Bitmap.Config bitmapConfig) { Bitmap.Config globalBitmapConfig = SubsamplingScaleImageView.getPreferredBitmapConfig(); if (bitmapConfig != null) { this.bitmapConfig = bitmapConfig; } else if (globalBitmapConfig != null) { this.bitmapConfig = globalBitmapConfig; } else { this.bitmapConfig = Bitmap.Config.RGB_565; } }
Example #13
Source File: SkiaImageRegionDecoder.java From subsampling-scale-image-view with Apache License 2.0 | 5 votes |
@SuppressWarnings({"WeakerAccess", "SameParameterValue"}) public SkiaImageRegionDecoder(@Nullable Bitmap.Config bitmapConfig) { Bitmap.Config globalBitmapConfig = SubsamplingScaleImageView.getPreferredBitmapConfig(); if (bitmapConfig != null) { this.bitmapConfig = bitmapConfig; } else if (globalBitmapConfig != null) { this.bitmapConfig = globalBitmapConfig; } else { this.bitmapConfig = Bitmap.Config.RGB_565; } }
Example #14
Source File: Image.java From Slide with GNU General Public License v3.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate( R.layout.submission_imagecard, container, false); final SubsamplingScaleImageView image = (SubsamplingScaleImageView) rootView.findViewById(R.id.image); TextView title = (TextView) rootView.findViewById(R.id.title); TextView desc = (TextView) rootView.findViewById(R.id.desc); title.setVisibility(View.GONE); desc.setVisibility(View.GONE); ((Reddit) getContext().getApplicationContext()).getImageLoader() .loadImage(url, new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { image.setImage(ImageSource.bitmap(loadedImage)); } }); return rootView; }
Example #15
Source File: ImageViewerLayout.java From hipda with GNU General Public License v2.0 | 5 votes |
protected void displayScaleImage() { ImageInfo imageInfo = ImageContainer.getImageInfo(mUrl); mScaleImageView.setMinimumDpi(36); mScaleImageView.setMinimumTileDpi(160); mScaleImageView.setOrientation(SubsamplingScaleImageView.ORIENTATION_USE_EXIF); mScaleImageView.setImage(ImageSource.uri(imageInfo.getPath())); mScaleImageView.setBitmapDecoderFactory(new CompatDecoderFactory<ImageDecoder>(SkiaImageDecoder.class, Utils.getBitmapConfig())); mScaleImageView.setRegionDecoderFactory(new CompatDecoderFactory<ImageRegionDecoder>(SkiaImageRegionDecoder.class, Utils.getBitmapConfig())); mScaleImageView.setOnClickListener(getOnClickListener()); mScaleImageView.setOnImageEventListener(new SubsamplingScaleImageView.DefaultOnImageEventListener() { @Override public void onImageLoaded() { if (mImageView.getVisibility() == VISIBLE) { mRequestManager.clear(mImageView); mImageView.setVisibility(View.GONE); } mScaleImageView.setVisibility(View.VISIBLE); if (imageInfo.isLongImage()) { float scale = (float) mScaleImageView.getWidth() / imageInfo.getWidth(); mScaleImageView.animateScaleAndCenter(scale, new PointF(mScaleImageView.getWidth() / 2, 0)) .withDuration(500) .withEasing(SubsamplingScaleImageView.EASE_OUT_QUAD) .withInterruptible(false) .start(); mScaleImageView.setDoubleTapZoomScale(scale); } } @Override public void onImageLoadError(Exception e) { mRequestManager.clear(mImageView); mImageView.setVisibility(View.GONE); mProgressBar.setError(); } }); }
Example #16
Source File: ZoomingImageView.java From Silence with GNU General Public License v3.0 | 5 votes |
public ZoomingImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); inflate(context, R.layout.zooming_image_view, this); this.imageView = (ImageView) findViewById(R.id.image_view); this.subsamplingImageView = (SubsamplingScaleImageView) findViewById(R.id.subsampling_image_view); this.imageViewAttacher = new PhotoViewAttacher(imageView); this.subsamplingImageView.setBitmapDecoderClass(AttachmentBitmapDecoder.class); this.subsamplingImageView.setRegionDecoderClass(AttachmentRegionDecoder.class); this.subsamplingImageView.setOrientation(SubsamplingScaleImageView.ORIENTATION_USE_EXIF); }
Example #17
Source File: MediaViewerActivity.java From Pix-Art-Messenger with GNU General Public License v3.0 | 5 votes |
private void DisplayImage(final File file, final Uri uri) { final boolean gif = "image/gif".equalsIgnoreCase(getMimeType(file.toString())); BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(new File(file.getPath()).getAbsolutePath(), options); height = options.outHeight; width = options.outWidth; rotation = getRotation(Uri.parse("file://" + file.getAbsolutePath())); Log.d(Config.LOGTAG, "Image height: " + height + ", width: " + width + ", rotation: " + rotation); if (useAutoRotateScreen()) { rotateScreen(width, height, rotation); } try { if (gif) { binding.messageGifView.setVisibility(View.VISIBLE); binding.messageGifView.setImageURI(uri); binding.messageGifView.setOnTouchListener((view, motionEvent) -> gestureDetector.onTouchEvent(motionEvent)); } else { binding.messageImageView.setVisibility(View.VISIBLE); binding.messageImageView.setImage(ImageSource.uri(uri)); binding.messageImageView.setOrientation(SubsamplingScaleImageView.ORIENTATION_USE_EXIF); binding.messageImageView.setOnTouchListener((view, motionEvent) -> gestureDetector.onTouchEvent(motionEvent)); } } catch (Exception e) { ToastCompat.makeText(this, getString(R.string.error_file_corrupt), Toast.LENGTH_LONG).show(); e.printStackTrace(); } }
Example #18
Source File: ArtboardView.java From mirror with GNU General Public License v3.0 | 5 votes |
private GestureDetector.SimpleOnGestureListener buildSimpleOnGestureListener() { return new GestureDetector.SimpleOnGestureListener() { @Override public boolean onDoubleTap(MotionEvent event) { if (!isReady()) { return true; } float scale; float screenWidth = DisplayUtils.getScreenWidth(getContext()); if (getSWidth() >= getSHeight()) { if (getSWidth() >= screenWidth) { scale = getMinScale(); } else { scale = screenWidth / (float) getSWidth(); } } else { scale = screenWidth / (float) getSWidth(); } animateScaleAndCenter(!isScaling() ? scale : getMinScale(), new PointF(event.getX(), event.getY())) .withDuration(AnimUtils.DURATION) .withEasing(SubsamplingScaleImageView.EASE_OUT_QUAD) .withInterruptible(false) .start(); return true; } }; }
Example #19
Source File: SkiaImageDecoder.java From subsampling-scale-image-view with Apache License 2.0 | 5 votes |
@SuppressWarnings({"WeakerAccess", "SameParameterValue"}) public SkiaImageDecoder(@Nullable Bitmap.Config bitmapConfig) { Bitmap.Config globalBitmapConfig = SubsamplingScaleImageView.getPreferredBitmapConfig(); if (bitmapConfig != null) { this.bitmapConfig = bitmapConfig; } else if (globalBitmapConfig != null) { this.bitmapConfig = globalBitmapConfig; } else { this.bitmapConfig = Bitmap.Config.RGB_565; } }
Example #20
Source File: PhotoPreviewActivity.java From privacy-friendly-shopping-list with Apache License 2.0 | 5 votes |
@Override protected final void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.product_photo_preview_activity); Bundle extras = getIntent().getExtras(); productId = (String) extras.get(ProductsActivity.PRODUCT_ID_KEY); productName = (String) extras.get(ProductsActivity.PRODUCT_NAME); calledFromDialog = (boolean) extras.get(ProductsActivity.FROM_DIALOG); setTitle(productName); SubsamplingScaleImageView productImage = (SubsamplingScaleImageView) findViewById(R.id.product_image_in_viewer); ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_bar); AbstractInstanceFactory instanceFactory = new InstanceFactory(this); productService = (ProductService) instanceFactory.createInstance(ProductService.class); String listDialogTitle = getResources().getString(R.string.product_as_title, productName); setTitle(listDialogTitle); loadImageFromStorage(productId) .doOnNext(result -> fullSizeBitmap = result) .doOnCompleted(() -> { progressBar.setVisibility(View.GONE); productImage.setImage(ImageSource.bitmap(fullSizeBitmap)); }) .doOnError(Throwable::printStackTrace) .subscribe(); }
Example #21
Source File: FourFragment.java From AndroidAnimationExercise with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment Log.e(TAG, "onCreateView: "); if (null != rootView) { ViewGroup parent = (ViewGroup) rootView.getParent(); if (null != parent) { parent.removeView(rootView); } } else { rootView = inflater.inflate(R.layout.fragment_four, container, false); loadData(); } final SubsamplingScaleImageView imageView = rootView.findViewById(R.id.image); imageView.setImage(ImageSource.resource(R.drawable.cat)); rootView.findViewById(R.id.reload).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(a){ imageView.setImage(ImageSource.resource(R.drawable.a5)); }else { imageView.setImage(ImageSource.resource(R.drawable.cat)); } a=!a; } }); return rootView; }
Example #22
Source File: SetWallpaperActivity.java From Camera-Roll-Android-App with Apache License 2.0 | 5 votes |
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); SubsamplingScaleImageView imageView = findViewById(R.id.imageView); outState.putSerializable(IMAGE_VIEW_STATE, imageView.getState()); }
Example #23
Source File: SetWallpaperActivity.java From Camera-Roll-Android-App with Apache License 2.0 | 5 votes |
private Rect getCroppedRect() { SubsamplingScaleImageView imageView = findViewById(R.id.imageView); PointF center = imageView.getCenter(); if (center != null) { int left = (int) (center.x - imageView.getWidth() / 2); return new Rect(left, 0, imageView.getSWidth(), imageView.getSHeight()); } return new Rect(0, 0, imageView.getSWidth(), imageView.getSHeight()); }
Example #24
Source File: SetWallpaperActivity.java From Camera-Roll-Android-App with Apache License 2.0 | 5 votes |
private void setWallpaper(int which) { try { WallpaperManager wallpaperManager = WallpaperManager.getInstance(this); InputStream inputStream = getContentResolver().openInputStream(imageUri); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { Rect croppedRect = getCroppedRect(); switch (which) { case HOME_SCREEN: wallpaperManager.setStream(inputStream, croppedRect, true, WallpaperManager.FLAG_SYSTEM); break; case LOCK_SCREEN: wallpaperManager.setStream(inputStream, croppedRect, true, WallpaperManager.FLAG_LOCK); break; case BOTH: wallpaperManager.setStream(inputStream, croppedRect, true); break; } } else { wallpaperManager.setStream(inputStream); } SubsamplingScaleImageView imageView = findViewById(R.id.imageView); imageView.recycle(); this.finish(); } catch (IOException | IllegalArgumentException e) { e.printStackTrace(); Toast.makeText(this, R.string.error, Toast.LENGTH_SHORT).show(); } }
Example #25
Source File: PhotoViewHolder.java From Camera-Roll-Android-App with Apache License 2.0 | 5 votes |
@Override public void onDestroy() { final SubsamplingScaleImageView imageView = itemView.findViewById(R.id.subsampling); if (imageView != null) { imageView.recycle(); } super.onDestroy(); }
Example #26
Source File: NovelImageActivity.java From light-novel-library_Wenku8_Android with GNU General Public License v2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_image); mSwipeBackLayout = getSwipeBackLayout(); mSwipeBackLayout.setScrimColor(Color.TRANSPARENT); mSwipeBackLayout.setEdgeTrackingEnabled(SwipeBackLayout.EDGE_LEFT); imgPath = getIntent().getStringExtra("path"); if (imgPath == null || imgPath.length() == 0) { Toast.makeText(this, "No image path error", Toast.LENGTH_LONG) .show(); return; } if (imgPath == null || imgPath.length() == 0) return; // load image file first imgContent = LightCache.loadFile(imgPath); bm = BitmapFactory.decodeByteArray(imgContent, 0, imgContent.length); // Native memory try // BitmapFactory.Options options = new BitmapFactory.Options(); // options.inPreferredConfig = Config.ARGB_8888; // options.inPurgeable = true;//允许可清除 // options.inInputShareable = true;// 以上options的两个属性必须联合使用才会有效果 // InputStream is = new ByteArrayInputStream(imgContent); // Bitmap bitmap = BitmapFactory.decodeStream(is,null,options); // ((PhotoView) // this.findViewById(R.id.image_photoview)).setImageBitmap(bitmap); // show in View SubsamplingScaleImageView iv = (SubsamplingScaleImageView) this.findViewById(R.id.image_photoview); iv.setImageFile(imgPath); return; }
Example #27
Source File: DisplayOptimizeListener.java From ImageLoader with Apache License 2.0 | 4 votes |
@Override public void onReady() { float result = 0.5f; int imageWidth = mImageView.getSWidth(); int imageHeight = mImageView.getSHeight(); int viewWidth = mImageView.getWidth(); int viewHeight = mImageView.getHeight(); boolean hasZeroValue = false; if (imageWidth == 0 || imageHeight == 0 || viewWidth == 0 || viewHeight == 0) { result = 0.5f; hasZeroValue = true; } if (!hasZeroValue) { if (imageWidth <= imageHeight) { result = (float) viewWidth / imageWidth; } else { result = (float) viewHeight / imageHeight; } } if (!hasZeroValue && (float) imageHeight / imageWidth > LONG_IMAGE_SIZE_RATIO) { // scale at top mImageView .animateScaleAndCenter(result, new PointF(imageWidth / 2, 0)) .withEasing(SubsamplingScaleImageView.EASE_OUT_QUAD) .start(); } // `对结果进行放大裁定,防止计算结果跟双击放大结果过于相近` if (Math.abs(result - 0.1) < 0.2f) { result += 0.2f; } if (mInitScaleType == BigImageView.INIT_SCALE_TYPE_AUTO) { float maxScale = Math.max((float) viewWidth / imageWidth, (float) viewHeight / imageHeight); if (maxScale > 1) { // image is smaller than screen, it should be zoomed out to its origin size mImageView.setMinScale(1); // and it should be zoomed in to fill the screen float defaultMaxScale = mImageView.getMaxScale(); mImageView.setMaxScale(Math.max(defaultMaxScale, maxScale * 1.2F)); } else { // image is bigger than screen, it should be zoomed out to fit the screen float minScale = Math.min((float) viewWidth / imageWidth, (float) viewHeight / imageHeight); mImageView.setMinScale(minScale); // but no need to set max scale } // scale to fit screen, and center mImageView.setScaleAndCenter(maxScale, new PointF(imageWidth / 2, imageHeight / 2)); } mImageView.setDoubleTapZoomScale(result); }
Example #28
Source File: DisplayOptimizeListener.java From ImageLoader with Apache License 2.0 | 4 votes |
public DisplayOptimizeListener(SubsamplingScaleImageView imageView) { mImageView = imageView; }
Example #29
Source File: ConfigurationActivity.java From subsampling-scale-image-view with Apache License 2.0 | 4 votes |
@Override protected void onPageChanged(int page) { if (page == 0) { view.setMinimumDpi(50); } else { view.setMaxScale(2F); } if (page == 1) { view.setMinimumTileDpi(50); } else { view.setMinimumTileDpi(320); } if (page == 4) { view.setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_CENTER); } else if (page == 5) { view.setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_CENTER_IMMEDIATE); } else { view.setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_FIXED); } if (page == 6) { view.setDoubleTapZoomDpi(240); } else { view.setDoubleTapZoomScale(1F); } if (page == 7) { view.setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_CENTER); } else if (page == 8) { view.setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_OUTSIDE); } else { view.setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_INSIDE); } if (page == 9) { view.setDebug(true); } else { view.setDebug(false); } if (page == 2) { view.setScaleAndCenter(0f, new PointF(3900, 3120)); view.setPanEnabled(false); } else { view.setPanEnabled(true); } if (page == 3) { view.setScaleAndCenter(1f, new PointF(3900, 3120)); view.setZoomEnabled(false); } else { view.setZoomEnabled(true); } }
Example #30
Source File: BasicFeaturesActivity.java From subsampling-scale-image-view with Apache License 2.0 | 4 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); SubsamplingScaleImageView view = findViewById(id.imageView); view.setImage(ImageSource.asset("sanmartino.jpg")); }