[Huawei Developers] Freemind R:
More information like this, you can visit HUAWEI Developer Forum​

Original link: https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0202327021435990014&fid=0101187876626530001

Introduction

Image kit provides 2 SDKs, the image vision SDK and Image Render SDK. We can add animations to your photos in minutes. The image render service provides 5 basic animation effects and 9 advanced effects.

Requirements

1. Huawei Device (Currently it will not support non-Huawei devices).

2. EMUI 8.1 above.

3. Minimum Android SDK version 26.

Use Cases

1. Image post processing: It provides 20 effects for the image processing and achieving high-quality image.

2. Theme design: Applies animations lock screens, wallpapers and themes

Steps

1. Create App in Android

2. Configure App in AGC

3. Integrate the SDK in our new Android project

4. Integrate the dependencies

5. Sync project

Integration

Create Application in Android Studio.

App level gradle depenencies.

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

Image kit dependencies

implementation 'com.huawei.hms:image-render:1.0.2.302'

Kotlin dependencies

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

Root level gradle dependencies

maven {url 'http://developer.huawei.com/repo/'}
classpath 'com.huawei.agconnect:agcp:1.3.1.300'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

To use the image render API, we need to provide resource files including images and manifest.xml files. Using image render service will parse the manifest.xml

Below parameters can be used in ImageRender API.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/767/951/2640091000001767951.20200813115138.70188855498677341374124684386643:50510901055400:2800:BDBE3600A1FB516874DB53B481DCA5A2B0E16686B81562B5A9E8099613EF629D.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/767/951/2640091000001767951.20200813115138.70188855498677341374124684386643:50510901055400:2800:BDBE3600A1FB516874DB53B481DCA5A2B0E16686B81562B5A9E8099613EF629D.png[/IMG]

Create Instance for ImageRenderImpl by calling the getInstance() method. To call this method app must implement callback method OnSuccess(), OnFailure(). If the ImageRender instance is successfully obtained.

fun initImageRender() {
ImageRender.getInstance(this, object : RenderCallBack {
override fun onSuccess(imageRender: ImageRenderImpl) {
showToast("ImageRenderAPI success")
imageRenderApi = imageRender
useImageRender()
}
override fun onFailure(i: Int) {
showToast("ImageRenderAPI failure, errorCode = $i")
}
})
}

Initialize Render service we need to pass source path and authJson, we can use the service after successfully authenticated.

fun useImageRender() {
val initResult: Int = imageRenderApi!!.doInit(sourcePath, authJson)
showToast("DoInit result == $initResult")
if (initResult == 0) {
val renderView: RenderView = imageRenderApi!!.getRenderView()
if (renderView.resultCode == ResultCode.SUCCEED) {
val view = renderView.view
if (null != view) {
frameLayout!!.addView(view)
}
}
} else {
showToast("Do init fail, errorCode == $initResult")
}
}

The Image Render service parses the image and script in sourcepath getRenderView() API will return the rendered views to the app.

User interaction is supported for advanced animation views.

fun initAuthJson() {
try {
authJson = JSONObject(string)
} catch (e: JSONException) {
System.out.println(e)
}
}

fun playAnimation(filterType: String) {
if (!Utils.copyAssetsFilesToDirs(this, filterType, sourcePath!!)) {
showToast("copy files failure, please check permissions")
return
}
if (imageRenderApi != null && frameLayout!!.childCount > 0) {
frameLayout!!.removeAllViews()
imageRenderApi!!.removeRenderView()
val initResult: Int = imageRenderApi!!.doInit(sourcePath, authJson)
showToast("DoInit result == $initResult")
if (initResult == 0) {
val renderView: RenderView = imageRenderApi!!.getRenderView()
if (renderView.resultCode == ResultCode.SUCCEED) {
val view = renderView.view
if (null != view) {
frameLayout!!.addView(view)
}
}
} else {
showToast("Do init fail, errorCode == $initResult")
}
}
}

Result:

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/767/951/2640091000001767951.20200813123606.98446849250150655196798096814009:50510901055400:2800:FE5C70AA7407E2B81FF713959FB561D65794155DE790FD5F627228B77635AB61.gif"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/767/951/2640091000001767951.20200813123606.98446849250150655196798096814009:50510901055400:2800:FE5C70AA7407E2B81FF713959FB561D65794155DE790FD5F627228B77635AB61.gif[/IMG]

Reference:

To know more about Image kit, check below URLs.

Image Kit:

https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides-V5/render-service-dev-0000001050197008-V5

Image Editor Article:

https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201320928748890264&fid=0101187876626530001

GitHub:

https://github.com/DTSE-India-Community/HMS-Image-Kit