Search code examples
c#androidxamarinfresco

Use fresco (facebook image library) to get scaled portion from the entire original image


Basically i i have source image and i want to get scaled down region from the entire image. In the end i am expecting scaled down portion with same aspect ratio as that that of entire source image. Is it possible? If so please guide me what should i be looking at.


Solution

  • You should look into Fresco Documentation here

    They say:

    To scale, simply specify the layout_width and layout_height of your SimpleDraweeView, as you would for any Android view. Then specify a scale type.

    And for resizing you can make something like this:

    Uri uri = "your uri";
    
    int width = 50, height = 50;
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
    .setResizeOptions(new ResizeOptions(width, height))
    .build();
    PipelineDraweeController controller = Fresco.newDraweeControllerBuilder()
    .setOldController(mDraweeView.getController())
    .setImageRequest(request)
    .build();
    mSimpleDraweeView.setController(controller);