0

The progressive jpeg config can be setted when initializing Fresco.

ImagePipelineConfig config = ImagePipelineConfig.newBuilder(context)
    .setProgressiveJpegConfig(progressiveJpegConfig)
    .build();
Fresco.initialize(context, config);

Now I want to loading the progressive jpeg in different scan quality, is there any way to achieve it?

Katy
  • 1
  • 2
  • What do you mean by "different scan quality"? Different progessive JPEG configs for different images? – Alexander Oprisnik Sep 18 '17 at 09:42
  • There are two methods `getNextScanNumberToDecode` and `getQualityInfo` defined in `ProgressiveJpegConfig`. Like the [this](https://github.com/facebook/fresco/blob/master/imagepipeline/src/main/java/com/facebook/imagepipeline/decoder/SimpleProgressiveJpegConfig.java), and I want to customized the `GoodEnoughScanNumber` in different scenario. – Katy Sep 19 '17 at 01:27
  • for example, I want to set enough scan number to 5 in A-Acitvity, and set to 10 in B-Activity. Is there any way to achieve it? – Katy Sep 19 '17 at 01:39
  • I see. I've posted an answer below but out of curiosity: Why do you need to do that? – Alexander Oprisnik Sep 19 '17 at 16:27

1 Answers1

0

Unfortunately, this is not supported right now. However, a workaround that could help here:

  • Create a delegating progressive JPEG config
  • In Activity A, call delegate.setConfig(configA)
  • In Activity B, call delegate.setConfig(configB)

This is not a perfect solution and if there are still image request from A in flight while B is active, you might end up in an inconsistent state, but it should work.

For proper support, either the ProducerFactory, DecodeProducer or the PJPEG config would need to be changed on the Fresco side. Pull requests are always welcome.

Alexander Oprisnik
  • 1,212
  • 9
  • 9
  • Sorry, I don't really understand how to create the delegating progressive JPEG config and to modify it. Can you provide the example with more detail. Thank you. – Katy Sep 21 '17 at 01:38