Fresco: Rotation for resource image not working

Created on 13 Jul 2017  路  4Comments  路  Source: facebook/fresco

Description

Rotation for resource image not work. Image is not rotated.

Reproduction

SimpleDraweeView iv = ...
ImageRequest ir = ImageRequestBuilder.newBuilderWithSource(R.drawable.sample_image)
                            .setRotationOptions(RotationOptions.forceRotation(RotationOptions.ROTATE_90))
                            .build();
DraweeController controller = Fresco.newDraweeControllerBuilder()
                            .setOldController(iv.getController())
                            .setImageRequest(ir)
                            .build();
iv.setController(controller);

Additional Information

  • Fresco version: 1.3.0
  • Platform version: min sdk 15
    ```
bug help wanted

Most helpful comment

Hello, I also try @YkSix code in fresco 1.9.0 for any image type (jpg, png), it's code work for Marshmellow and Nougat. But, for Oreo, the image zoom in and the view looks like rotated. I want to know why in Oreo different, maybe Oreo have a new type to handle?

All 4 comments

Thanks, I verified that this actually doesn't work right now.

Fresco currently only supports JPG images rotation. For other image types, it can be done by using Postprocessor:

ImageRequest ir = ImageRequestBuilder.newBuilderWithResourceId(R.drawable. sample_image)
    .setPostprocessor(new BasePostprocessor() {
      @Override
      public CloseableReference<Bitmap> process(
          Bitmap sourceBitmap, PlatformBitmapFactory bitmapFactory) {

        Matrix matrix = new Matrix();
        matrix.setRotate(90);

        CloseableReference<Bitmap> bitmapRef = bitmapFactory.createBitmap(sourceBitmap, 0, 0, sourceBitmap.getWidth(), sourceBitmap.getHeight(), matrix, true);
        try {
          return CloseableReference.cloneOrNull(bitmapRef);
        } finally {
          CloseableReference.closeSafely(bitmapRef);
        }
      }
    })
    .build();

Hello, I also try @YkSix code in fresco 1.9.0 for any image type (jpg, png), it's code work for Marshmellow and Nougat. But, for Oreo, the image zoom in and the view looks like rotated. I want to know why in Oreo different, maybe Oreo have a new type to handle?

This issue should be fixed now, we tried to repro and it seems to work. If it is still an issue, please let us know.

Was this page helpful?
0 / 5 - 0 ratings