Search in sources :

Example 1 with ImageRegionDecoder

use of com.davemorrissey.labs.subscaleview.decoder.ImageRegionDecoder in project subsampling-scale-image-view by davemorrissey.

the class ImageDisplayRegionFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(layout.imagedisplay_region_fragment, container, false);
    final SubsamplingScaleImageView imageView = rootView.findViewById(id.imageView);
    imageView.setBitmapDecoderFactory(new CompatDecoderFactory<ImageDecoder>(SkiaImageDecoder.class, Bitmap.Config.ARGB_8888));
    imageView.setRegionDecoderFactory(new CompatDecoderFactory<ImageRegionDecoder>(SkiaImageRegionDecoder.class, Bitmap.Config.ARGB_8888));
    imageView.setOrientation(SubsamplingScaleImageView.ORIENTATION_90);
    imageView.setImage(ImageSource.asset("card.png").region(new Rect(5200, 651, 8200, 3250)));
    final ImageDisplayActivity activity = (ImageDisplayActivity) getActivity();
    if (activity != null) {
        rootView.findViewById(id.previous).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                activity.previous();
            }
        });
    }
    rootView.findViewById(id.rotate).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            imageView.setOrientation((imageView.getOrientation() + 90) % 360);
        }
    });
    return rootView;
}
Also used : Rect(android.graphics.Rect) ImageRegionDecoder(com.davemorrissey.labs.subscaleview.decoder.ImageRegionDecoder) SkiaImageRegionDecoder(com.davemorrissey.labs.subscaleview.decoder.SkiaImageRegionDecoder) SkiaImageDecoder(com.davemorrissey.labs.subscaleview.decoder.SkiaImageDecoder) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) ImageDecoder(com.davemorrissey.labs.subscaleview.decoder.ImageDecoder) SkiaImageDecoder(com.davemorrissey.labs.subscaleview.decoder.SkiaImageDecoder) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) View(android.view.View) SkiaImageRegionDecoder(com.davemorrissey.labs.subscaleview.decoder.SkiaImageRegionDecoder)

Aggregations

Rect (android.graphics.Rect)1 View (android.view.View)1 SubsamplingScaleImageView (com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView)1 ImageDecoder (com.davemorrissey.labs.subscaleview.decoder.ImageDecoder)1 ImageRegionDecoder (com.davemorrissey.labs.subscaleview.decoder.ImageRegionDecoder)1 SkiaImageDecoder (com.davemorrissey.labs.subscaleview.decoder.SkiaImageDecoder)1 SkiaImageRegionDecoder (com.davemorrissey.labs.subscaleview.decoder.SkiaImageRegionDecoder)1