O
O
OM12016-11-16 10:49:08
Android
OM1, 2016-11-16 10:49:08

Android Studio: how to load bitmap as Marker using picasso or fresco?

Good afternoon.
There is a common error in picasso when working with target: onBitmapLoaded does not fire.
How else can you use the loaded bitmap without attaching it to the imageView?
When working with fresco, I used the image loading method via ImagePipeline and dataSource.subscribe(new BaseBitmapDataSubscriber()), CallerThreadExecutor.getInstance());
, but without success
How to load the bitmap not in the imageView, but for further use in the code?
Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Perelygin, 2016-11-16
@OM1

Well frescolib makes it pretty easy to do this. Just read the docs: frescolib.org/docs/using-image-pipeline.html

O
OM1, 2016-11-16
@OM1

While I made a crutch on Picasso using transform:

ImageView imageview = new ImageView(MainActivity.this);

                Picasso.with(getApplication())
                        .load(url)
                        .transform(new CropSquareTransformation())
                        .into(imageview);



public class CropSquareTransformation implements Transformation {

        @Override public Bitmap transform(Bitmap source) {

            Log.w("MY", "Bitmap transform(Bitmap source)");

            int size = Math.min(source.getWidth(), source.getHeight());
            int x = (source.getWidth() - size) / 2;
            int y = (source.getHeight() - size) / 2;

            Bitmap result = Bitmap.createBitmap(source, x, y, size, size);

            MY_FUNCTION(result);

            if (result != source) {
                source.recycle();
            }



            return result;
        }

        @Override public String key() { return "square()"; }
    }

Not quite beautiful, I'm using an imageview that I don't need.
How to optimize?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question