To make it easier and faster for you to use CI's basic image processing features and CDN's image delivery features, we provide the following five modules for your choice as needed:
Module | Feature |
---|---|
cloud-infinite (default module) | This module contains CI's basic image processing operations and supports freely combining various operations to build URLs for network requests. |
cloud-infinite-loader | This module uses the CIImageLoadRequest instance to request online images and return image data. |
TPG | This module decodes and displays general images and TPG images. |
AVIF | This module decodes and displays general images and AVIF images. |
cloud-infinite-glide | This module depends on the glide and cloud-infinite modules to provide CI's basic image processing features. |
Note:
- For more information on TPG, see TPG Compression.
The cloud-infinite
module has the following main features:
Use Gradle for integration
Note:As the Bintray repository is no longer available, CI's SDKs have been migrated to Maven Central. The import path is different, so you need to use the new import path during the update.
Add the following code to the project-level build.gradle
file (usually in the root directory):
repositories {
google()
// Add the following line
mavenCentral()
}
Add the following to the build.gradle
of your app or other class libraries:
implementation 'com.qcloud.cos:cloud-infinite:1.2.1'
When using CloudInfinite to build a CI-enabled image URL, you first need to instantiate the CloudInfinite class.
CloudInfinite cloudInfinite = new CloudInfinite();
Instantiate the image transformation class CITransformation
and set related operations. The following takes TPG as an example. For more features, see Basic Image Processing.
CITransformation transform = new CITransformation();
transform.format(CIImageFormat.TPG, CIImageLoadOptions.LoadTypeUrlFooter)
Use the CloudInfinite instance to build a CI-enabled image URL.
Build synchronously
CIImageLoadRequest request = cloudInfinite.requestWithBaseUrlSync(objectUrl, transform);
// Image URL
URL imageURL = request.getUrl();
// Header parameter
Map<String, List<String>> heaers = request.getHeaders();
Build asynchronously
cloudInfinite.requestWithBaseUrl(objectUrl, transform, new CloudInfiniteCallback() {
@Override
public void onImageLoadRequest(@NonNull final CIImageLoadRequest request) {
// Image URL
URL imageURL = request.getUrl();
// Header parameter
Map<String, List<String>> heaers = request.getHeaders();
}
});
Note:The header parameter of CIImageLoadRequest is valid only when image format conversion is performed and
options
is set toLoadTypeAcceptHeader
.
After successfully building the CIImageLoadRequest instance, use the cloud-infinite-loader SDK to load an image.
Integrate the cloud-infinite-loader SDK.
implementation 'com.qcloud.cos:cloud-infinite-loader:1.2.1'
Add the INTERNET permission.
<uses-permission android:name="android.permission.INTERNET" />
Load the image.
Directly load ImageView
CIImageLoader ciImageLoader = new CIImageLoader();
ciImageLoader.display(request, imageview);
Request image data
CIImageLoader ciImageLoader = new CIImageLoader();
ciImageLoader.loadData(request, new CIImageLoadDataCallBack() {
@Override
public void onLoadData(byte[] bytes) {
// Use the pseudocode to set bytes data for the imageview
//imageview.setBytes(bytes);
}
@Override
public void onFailure(QCloudClientException clientException, QCloudServiceException serviceException) {
}
});
Was this page helpful?