我正在尝试构建一个Android应用程序以及使用Photoeditor SDK(https://www.photoeditorsdk.com/; Github - https://github.com/imgly/pesdk-android-demo)。这个repo有完整的代码来使用SDK,但我只需要SDK中的过滤器部分。
如何使用?
我尝试实现依赖项并调用其文档中提供的过滤器,
ArrayList<<ColorFilter>> filter = new ArrayList<>();
filter.add(new NoneColorFilter());
filter.add(new ColorFilterAD1920());
filter.add(new ColorFilterAncient());
filter.add(new ColorFilterBleached());
filter.add(new ColorFilterBleachedBlue());
filter.add(new ColorFilterBlues());
filter.add(new ColorFilterBlueShadows());
filter.add(new ColorFilterBreeze());
filter.add(new ColorFilterBW());
filter.add(new ColorFilterCelsius());
filter.add(new ColorFilterClassic());
filter.add(new ColorFilterColorful());
filter.add(new ColorFilterCool());
filter.add(new ColorFilterCottonCandy());
filter.add(new ColorFilterCreamy());
filter.add(new ColorFilterEighties());
filter.add(new ColorFilterElder());
filter.add(new ColorFilterEvening());
filter.add(new ColorFilterFall());
filter.add(new ColorFilterFixie());
filter.add(new ColorFilterFood());
filter.add(new ColorFilterFridge());
filter.add(new ColorFilterFront());
filter.add(new ColorFilterGlam());
filter.add(new ColorFilterHighCarb());
filter.add(new ColorFilterHighContrast());
filter.add(new ColorFilterK1());
filter.add(new ColorFilterK2());
filter.add(new ColorFilterK6());
filter.add(new ColorFilterKDynamic());
filter.add(new ColorFilterKeen());
filter.add(new ColorFilterLenin());
filter.add(new ColorFilterLitho());
filter.add(new ColorFilterLomo());
filter.add(new ColorFilterLomo100());
filter.add(new ColorFilterLucid());
filter.add(new ColorFilterMellow());
filter.add(new ColorFilterNeat());
filter.add(new ColorFilterNoGreen());
filter.add(new ColorFilterOrchid());
filter.add(new ColorFilterPale());
config.setFilter(filter);
但我无法取得它。怎么做到这一点?
答案 0 :(得分:1)
您只需使用FilterEditorTool作为设置列表中的唯一工具。
SettingsList settingsList = new SettingsList();
settingsList.getSettingsModel(EditorLoadSettings::class.java)
.setImageSourcePath(imagePath, true);
settingsList.getSettingsModel(EditorSaveSettings::class.java)
.setSavePolicy(EditorSaveSettings.SavePolicy.KEEP_SOURCE_AND_CREATE_ALWAYS_OUTPUT)
.setExportDir(filesDir.path + "/images");
ArrayList<ToolConfigInterface> tools = new ArrayList<>();
tools.add(FilterEditorTool(R.string.imgly_tool_name_filter, R.drawable.imgly_icon_tool_filters));
settingsList.getConfig().setTools(tools)
PhotoEditorBuilder(this).setSettingsList(settingsList).startActivityForResult(this, PHOTO_EDITOR_REQUEST_CODE)
Kotlin代码:
val settingsList = SettingsList().apply {
getSettingsModel(EditorLoadSettings::class.java)
.setImageSourcePath(imagePath, true)
getSettingsModel(EditorSaveSettings::class.java)
.setSavePolicy(EditorSaveSettings.SavePolicy.KEEP_SOURCE_AND_CREATE_ALWAYS_OUTPUT)
.setExportDir(filesDir.path + "/images")
val tools = arrayListOf<ToolConfigInterface>(
FilterEditorTool(R.string.imgly_tool_name_filter, R.drawable.imgly_icon_tool_filters),
)
config.setTools(tools)
}
PhotoEditorBuilder(this).setSettingsList(settingsList).startActivityForResult(this, PHOTO_EDITOR_REQUEST_CODE)