带有贴纸的 PhotoEditorSDK 设置列表作为其他图像的模板
PhotoEditorSDK settings list with stickers as template for other images
我使用 Photo Editor SDK 版本 5.0.20,并希望使用带有贴纸的序列化设置列表作为其他图像的模板。
基本上,我加载了一个之前序列化的设置列表,如Photo Editor SDK Docs中所述,其中仅包含对贴纸的操作:
{
"version": "3.0.0",
"meta": {
"platform": "android",
"version": "5.0.20",
"createdAt": "2018-04-16T07:22:41+00:00"
},
"operations": [
{
"type": "sprite",
"options": {
"sprites": [
{
"type": "sticker",
"options": {
"identifier": "Wimpel",
"dimensions": {
"x": 1.0390830937992344,
"y": 0.3552596348364971
},
"position": {
"x": 0.093109130859375,
"y": 0.028560863807797432
},
"flipVertically": false,
"flipHorizontally": false,
"tintColor": {
"rgba": [
0.0,
0.0,
0.0,
0.0
]
},
"rotation": 0.10879226105860895
}
},
{
"type": "sticker",
"options": {
"identifier": "Wimpel",
"dimensions": {
"x": 1.0693840954731448,
"y": 0.36561946347204366
},
"position": {
"x": 1.183990716934204,
"y": 0.2119801640510559
},
"flipVertically": false,
"flipHorizontally": false,
"tintColor": {
"rgba": [
0.0,
0.0,
0.0,
0.0
]
},
"rotation": 0.06839104205767087
}
},
{
"type": "sticker",
"options": {
"identifier": "Tasse",
"dimensions": {
"x": 0.4046522174597027,
"y": 0.28636926158686654
},
"position": {
"x": 0.731689453125,
"y": 0.8851687908172607
},
"flipVertically": false,
"flipHorizontally": false,
"tintColor": {
"rgba": [
0.0,
0.0,
0.0,
0.0
]
},
"rotation": 6.279117594930599
}
},
{
"type": "sticker",
"options": {
"identifier": "Mmmh",
"dimensions": {
"x": 0.27350121683039547,
"y": 0.25441973658641437
},
"position": {
"x": 0.604736328125,
"y": 0.7340571284294128
},
"flipVertically": false,
"flipHorizontally": false,
"tintColor": {
"rgba": [
0.0,
0.0,
0.0,
0.0
]
},
"rotation": 6.225312686163292
}
},
{
"type": "sticker",
"options": {
"identifier": "Lachende Shira",
"dimensions": {
"x": 0.32523648876287115,
"y": 0.5730795920977503
},
"position": {
"x": 0.1793212890625,
"y": 0.8109974265098572
},
"flipVertically": false,
"flipHorizontally": false,
"tintColor": {
"rgba": [
0.0,
0.0,
0.0,
0.0
]
},
"rotation": 0.007284810845802748
}
},
{
"type": "sticker",
"options": {
"identifier": "Busch",
"dimensions": {
"x": 0.38570687331007564,
"y": 0.2892801549825567
},
"position": {
"x": 0.157135009765625,
"y": 0.9686249494552612
},
"flipVertically": false,
"flipHorizontally": false,
"tintColor": {
"rgba": [
0.0,
0.0,
0.0,
0.0
]
},
"rotation": 0.010578608482012749
}
}
]
}
}
]
}
这些贴纸应该显示在加载的图像上,但不幸的是它不起作用。
我还尝试了其他序列化设置(例如过滤器),这些设置已正确应用于加载的图像。
是序列化有误JSON还是其他什么地方不对?
我发现我的自定义贴纸必须在序列化JSON读入配置之前设置为配置,否则序列化贴纸无法被SDK找到:
val settingsList = SettingsList().apply {
...
val tools = arrayListOf<ToolConfigInterface>(...)
val stickers = arrayListOf<StickerListConfigInterface>(...)
config.setTools(tools).setStickerLists(stickers)
val file = File(filesDir.path, "editor_template.json")
if (file.exists()) {
val reader = PESDKFileReader(this)
try {
reader.readJson(file)
Timber.d("Read editor state json.")
} catch (e: IOException) {
Timber.e(e, "Could not read editor state json.")
}
}
}
PhotoEditorBuilder(this).setSettingsList(settingsList).startActivityForResult(this, PHOTO_EDITOR_REQUEST_CODE)
我使用 Photo Editor SDK 版本 5.0.20,并希望使用带有贴纸的序列化设置列表作为其他图像的模板。
基本上,我加载了一个之前序列化的设置列表,如Photo Editor SDK Docs中所述,其中仅包含对贴纸的操作:
{
"version": "3.0.0",
"meta": {
"platform": "android",
"version": "5.0.20",
"createdAt": "2018-04-16T07:22:41+00:00"
},
"operations": [
{
"type": "sprite",
"options": {
"sprites": [
{
"type": "sticker",
"options": {
"identifier": "Wimpel",
"dimensions": {
"x": 1.0390830937992344,
"y": 0.3552596348364971
},
"position": {
"x": 0.093109130859375,
"y": 0.028560863807797432
},
"flipVertically": false,
"flipHorizontally": false,
"tintColor": {
"rgba": [
0.0,
0.0,
0.0,
0.0
]
},
"rotation": 0.10879226105860895
}
},
{
"type": "sticker",
"options": {
"identifier": "Wimpel",
"dimensions": {
"x": 1.0693840954731448,
"y": 0.36561946347204366
},
"position": {
"x": 1.183990716934204,
"y": 0.2119801640510559
},
"flipVertically": false,
"flipHorizontally": false,
"tintColor": {
"rgba": [
0.0,
0.0,
0.0,
0.0
]
},
"rotation": 0.06839104205767087
}
},
{
"type": "sticker",
"options": {
"identifier": "Tasse",
"dimensions": {
"x": 0.4046522174597027,
"y": 0.28636926158686654
},
"position": {
"x": 0.731689453125,
"y": 0.8851687908172607
},
"flipVertically": false,
"flipHorizontally": false,
"tintColor": {
"rgba": [
0.0,
0.0,
0.0,
0.0
]
},
"rotation": 6.279117594930599
}
},
{
"type": "sticker",
"options": {
"identifier": "Mmmh",
"dimensions": {
"x": 0.27350121683039547,
"y": 0.25441973658641437
},
"position": {
"x": 0.604736328125,
"y": 0.7340571284294128
},
"flipVertically": false,
"flipHorizontally": false,
"tintColor": {
"rgba": [
0.0,
0.0,
0.0,
0.0
]
},
"rotation": 6.225312686163292
}
},
{
"type": "sticker",
"options": {
"identifier": "Lachende Shira",
"dimensions": {
"x": 0.32523648876287115,
"y": 0.5730795920977503
},
"position": {
"x": 0.1793212890625,
"y": 0.8109974265098572
},
"flipVertically": false,
"flipHorizontally": false,
"tintColor": {
"rgba": [
0.0,
0.0,
0.0,
0.0
]
},
"rotation": 0.007284810845802748
}
},
{
"type": "sticker",
"options": {
"identifier": "Busch",
"dimensions": {
"x": 0.38570687331007564,
"y": 0.2892801549825567
},
"position": {
"x": 0.157135009765625,
"y": 0.9686249494552612
},
"flipVertically": false,
"flipHorizontally": false,
"tintColor": {
"rgba": [
0.0,
0.0,
0.0,
0.0
]
},
"rotation": 0.010578608482012749
}
}
]
}
}
]
}
这些贴纸应该显示在加载的图像上,但不幸的是它不起作用。
我还尝试了其他序列化设置(例如过滤器),这些设置已正确应用于加载的图像。
是序列化有误JSON还是其他什么地方不对?
我发现我的自定义贴纸必须在序列化JSON读入配置之前设置为配置,否则序列化贴纸无法被SDK找到:
val settingsList = SettingsList().apply {
...
val tools = arrayListOf<ToolConfigInterface>(...)
val stickers = arrayListOf<StickerListConfigInterface>(...)
config.setTools(tools).setStickerLists(stickers)
val file = File(filesDir.path, "editor_template.json")
if (file.exists()) {
val reader = PESDKFileReader(this)
try {
reader.readJson(file)
Timber.d("Read editor state json.")
} catch (e: IOException) {
Timber.e(e, "Could not read editor state json.")
}
}
}
PhotoEditorBuilder(this).setSettingsList(settingsList).startActivityForResult(this, PHOTO_EDITOR_REQUEST_CODE)