how to load bitmap directly with picasso library like following

picasso get load not working
picasso android
picasso get cannot resolve method
picasso get load retrieveprofileimage into userprofileimage
picasso recyclerview
how to load multiple images from url in android using picasso
load svg using picasso android
glide load bitmap
Picasso.with(context).load("url").into(imageView);

Here instead of url i want bitmap how can i achieve this. like below-

Picasso.with(context).load(bitmap).into(imageView);

This should work for you. Use the returned URI with Picasso.

(taken from: is there away to get uri of bitmap with out save it to sdcard?)

public Uri getImageUri(Context inContext, Bitmap inImage) {
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
    String path = MediaStore.Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null);
    return Uri.parse(path);
}

Displaying Images with the Picasso Library, Displaying images is easiest using a third party library such as Picasso from repositories { maven { url "https://oss.sonatype.org/content/repositories/snapshots​" } } // add directly We can then load a remote image into any ImageView with: Alternatively, we can set the ratio after the bitmap has loaded if we don't know  Android Picasso is an image loading and caching library, which developed and maintained by Square Inc. In this tutorial, we will learn how to load an image as a bitmap into ImageView using Picasso. Use the following code to load an image as a bitmap into ImageView using Picasso.

My Kotlin solution

create the bitmap from data

    val inputStream = getContentResolver().openInputStream(data.data)
    val bitmap = BitmapFactory.decodeStream(inputStream)
    val stream = ByteArrayOutputStream()
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream)

IMPORTANT: if you don't need to store the image you can avoid Picasso and load the image right away

    imageView.setImageBitmap(bitmap)

otherwise store the file and load it with Picasso

    val jpegData = stream.toByteArray()

    val file = File(cacheDir, "filename.jpg")
    file.createNewFile()

    val fileOS = FileOutputStream(file)
    fileOS.write(jpegData)
    fileOS.flush()
    fileOS.close()

    Picasso.get().load(Uri.parse(file.path)).into(imageView)

Picasso, Its better to create a data member to hold the reference and not lose it with gc. https://guides.codepath.com/android/Displaying-Images-with-the-  With ImageView, I can use the following code to download image with callback. Picasso.with(activity).load(url).into(imageView, new Callback() { @Override public void onSuccess() { // do something } @Override public void onError() { } );

private void loadBitmapByPicasso(Context pContext, Bitmap pBitmap, ImageView pImageView) {
    try {
        Uri uri = Uri.fromFile(File.createTempFile("temp_file_name", ".jpg", pContext.getCacheDir()));
        OutputStream outputStream = pContext.getContentResolver().openOutputStream(uri);
        pBitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
        outputStream.close();
        Picasso.get().load(uri).into(pImageView);
    } catch (Exception e) {
        Log.e("LoadBitmapByPicasso", e.getMessage());
    }
}

A simple example illustrating how to use Picasso to load a bitmap , Android Picasso Tutorial, image load from URL, android picasso cache Android Picasso comes with its own set of features such as: To load a image from URL in an ImageView using picasso api, following code We can further customise the bitmap image returned in the method onBitmapLoaded() or directly show it in  LoadedFrom from) {// Calculate the image ratio of the loaded bitmap float ratio = (float) bitmap. getHeight / (float) bitmap. getWidth (); // Set the ratio for the image ivImage. setHeightRatio (ratio); // Load the image into the view ivImage. setImageBitmap (bitmap);}}

You are using an old version of Picasso.

Update the version in your Gradle file:

implementation 'com.squareup.picasso:picasso:2.71828'

Java:

Picasso.get().load(R.drawable.landing_screen).into(imageView1);
Picasso.get().load("file:///android_asset/DvpvklR.png").into(imageView2);
Picasso.get().load(new File(...)).into(imageView3);

See more details on the Picasso website

Android Picasso Tutorial, Android Picasso Image does not load, In Picasso you shoud pass url in how to load bitmap directly with picasso library like following, This should work for you. Picasso Components: One simple statement like this loads an image Once we get an instance of Picasso, we now try to load an image url into an ImageView/Target. Return the bitmap from the

Why Picasso library is not working in my project, Use the following code to load an image as a bitmap into ImageView using Picasso. Picasso.with(this).load(url).into(new  LoadBitmap creates a compatible bitmap of the display, which cannot be selected to a printer. To load a bitmap that you can select to a printer, call LoadImage and specify LR_CREATEDIBSECTION to create a DIB section. A DIB section can be selected to any device. An application can use the LoadBitmap function to access predefined bitmaps.

Android Picasso load Bitmap, Note: There are several libraries that follow best practices for loading images. Other popular image loading libraries include Picasso from Square, Coil ideally you only want to load a lower resolution version in memory. Picasso one of the most popular library for android. It is very simple and powerful library for image downloading and caching. There are also some alternative libraries like Volley. I already a published a tutorial about Using Android Volley Library to Load Image From Internet. In this post we will learn about picasso android library. Why

Loading Large Bitmaps Efficiently, Picasso is an image downloading and caching library. When you Basic usage for displaying an image from a resource file into an ImageView is as follows: Picasso.with(this).load(R.drawable.ic_launcher).into(imageView);. Before getting into picasso library example, we should know about picasso. Picasso is image processing library and developed by Square Inc. In older days we used to write lengthy of codes to grab image from server or do process., to optimize the process picasso introduced.

Comments
  • Although it works it's not the best solution because it needs "write to storage" permission.
  • implementation 'com.squareup.picasso:picasso:2.71828'