0

我正在尝试使用 Photoeditor SDK ( https://www.photoeditorsdk.com/ ; Github - https://github.com/imgly/pesdk-android-demo ) 构建一个 android 应用程序。这个 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);

但我无法获取它。如何做到这一点?

4

1 回答 1

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)

科特林代码:

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)
于 2018-05-02T08:22:33.197 回答