Firstly, If we use multi Constraints such as ResolutionConstraint, QualityConstraint, FormatConstraint, DestinationConstraint, SizeConstraint, there will exists multi bitmap.compress() which is just like one(constraint) by one(constraint). For example, the code is as follows:
if each constraint spend 2s, then the compression of the above will spend 10s(the sum of each time cost). The result is not what we want.
Secondly, since the png which is lossless will ignore the compress quality setting, but in the SizeConstraint Class, the png format bitmap always will be applied the quality reducing multi times which is useless.
Solution:
Merge multi ResolutionConstraints and QualityConstraints and FormatConstraints (without DestinationConstraint and SizeConstraint) into only one DefaultConstraint.
Move the SizeConstraint to the last post since it can reduce the number of compress times in this type of SizeConstraint.
In SizeConstraint, we can avoid performing the compression if the bitmap compress format is png.
If there is a DestinationConstraint, we can reduce the number of copy file times via using the dest file from DestinationConstraint in the method of copyToCache.
Issue description:
bitmap.compress()
which is just like one(constraint) by one(constraint). For example, the code is as follows:if each constraint spend 2s, then the compression of the above will spend 10s(the sum of each time cost). The result is not what we want.
Solution:
ResolutionConstraints
andQualityConstraints
andFormatConstraints
(withoutDestinationConstraint
andSizeConstraint
) into only oneDefaultConstraint
.SizeConstraint
to the last post since it can reduce the number of compress times in this type ofSizeConstraint
.SizeConstraint
, we can avoid performing the compression if the bitmap compress format is png.DestinationConstraint
, we can reduce the number of copy file times via using the dest file fromDestinationConstraint
in the method ofcopyToCache
.