1

I need to disable Fresco downsampling for the <Image/> component and I read that Fresco needs to be initialized inside android/app/src/main/java/com/<project>/MainApplication.java.

Fresco > Resizing/Downsampling
Fresco > Configuring the Image Pipeline
RN issue report

I found two ways to do it but none of the themes worked and couldn't have Fresco image downsampling disabled:

1st override onCreate and initialize Fresco like this:

@Override
public void onCreate() {
  super.onCreate();

  Context context = getApplicationContext();
  ImagePipelineConfig config = ImagePipelineConfig.newBuilder(context)
    .setDownsampleEnabled(false)
    .build();
  Fresco.initialize(context, config);

  SoLoader.init(this, /* native exopackage */ false);
}

2nd initialize Fresco using MainReactPackage inside getPackages:

protected List<ReactPackage> getPackages() {
  Context context = getApplicationContext();
  ImagePipelineConfig frescoConfig = ImagePipelineConfig.newBuilder(context)
    .setDownsampleEnabled(false)
    .build();

  MainPackageConfig appConfig = new MainPackageConfig
    .Builder()
    .setFrescoConfig(frescoConfig)
    .build();

  return new ArrayList<>(Arrays.<ReactPackage>asList(
    new MainReactPackage(appConfig),
    new ReactNativeFirebaseAppPackage(),
    new FastImageViewPackage()
  ));
}

I'm currently on RN 0.60.5 and I'm extending MainApplication with com.reactnativenavigation.NavigationApplication because I'm using react-native-navigation.

My question is how can I disable Fresco image downsampling.

AmerllicA
  • 29,059
  • 15
  • 130
  • 154
Christos Lytras
  • 36,310
  • 4
  • 80
  • 113
  • 1
    Facing same in react-native 0.61 – Anurag Chutani Dec 18 '19 at 11:47
  • @AnuragChutani the solution for now is to clone the Fresco repo, comment the downsampling code and then compile Fresco and create your custom binaries which will be included in the APK. See this thread and my comment here https://github.com/facebook/fresco/issues/2397#issuecomment-541802753 – Christos Lytras Dec 18 '19 at 12:41
  • [This](https://i.stack.imgur.com/FWGae.jpg) is my report to the support team. – AmerllicA Apr 28 '20 at 23:37
  • I sent the report of my violation. don't worry. all downvotes will revert, and also I asked them to punish me. I'm light now. thanks for your responses. – AmerllicA Apr 28 '20 at 23:42
  • Yeah, You right, Ok, here is 5 a.m. I'm awake to pray, I sleep now and after awaking I will make a list of my ugly deeds. then I make a little change to them and revert what I did. thanks. – AmerllicA Apr 29 '20 at 00:13

0 Answers0