Extract brush package import targets
This commit is contained in:
@@ -876,8 +876,17 @@ bool NodePanelBrushPreset::import_ppbr(const std::string& path)
|
||||
{
|
||||
Image img;
|
||||
sr >> img;
|
||||
std::string path = App::I->data_path + "/brushes/" + img.file_name + "." + img.file_ext;
|
||||
std::string path_thumb = App::I->data_path + "/brushes/thumbs/" + img.file_name + "." + img.file_ext;
|
||||
const auto target_paths = pp::assets::plan_brush_package_image_target_paths(
|
||||
App::I->data_path,
|
||||
pp::assets::BrushPackageImageKind::brush_tip,
|
||||
img.file_name,
|
||||
img.file_ext);
|
||||
if (!target_paths) {
|
||||
LOG("import_ppbr invalid brush image target: %s", target_paths.status().message);
|
||||
return false;
|
||||
}
|
||||
const auto& path = target_paths.value().image_path;
|
||||
const auto& path_thumb = target_paths.value().thumbnail_path;
|
||||
if (!Asset::exist(path))
|
||||
{
|
||||
img.save_png(path);
|
||||
@@ -898,8 +907,17 @@ bool NodePanelBrushPreset::import_ppbr(const std::string& path)
|
||||
{
|
||||
Image img;
|
||||
sr >> img;
|
||||
std::string path = App::I->data_path + "/patterns/" + img.file_name + "." + img.file_ext;
|
||||
std::string path_thumb = App::I->data_path + "/patterns/thumbs/" + img.file_name + "." + img.file_ext;
|
||||
const auto target_paths = pp::assets::plan_brush_package_image_target_paths(
|
||||
App::I->data_path,
|
||||
pp::assets::BrushPackageImageKind::pattern,
|
||||
img.file_name,
|
||||
img.file_ext);
|
||||
if (!target_paths) {
|
||||
LOG("import_ppbr invalid pattern image target: %s", target_paths.status().message);
|
||||
return false;
|
||||
}
|
||||
const auto& path = target_paths.value().image_path;
|
||||
const auto& path_thumb = target_paths.value().thumbnail_path;
|
||||
if (!Asset::exist(path))
|
||||
{
|
||||
img.save_png(path);
|
||||
@@ -970,8 +988,17 @@ bool NodePanelBrushPreset::import_abr(const std::string& path)
|
||||
auto ii = abr.m_samples.begin();
|
||||
std::advance(ii, i);
|
||||
const auto& samp = *ii;
|
||||
std::string path_high = App::I->data_path + "/brushes/" + samp.first + ".png";
|
||||
std::string path_thumb = App::I->data_path + "/brushes/thumbs/" + samp.first + ".png";
|
||||
const auto target_paths = pp::assets::plan_brush_package_image_target_paths(
|
||||
App::I->data_path,
|
||||
pp::assets::BrushPackageImageKind::brush_tip,
|
||||
samp.first,
|
||||
"png");
|
||||
if (!target_paths) {
|
||||
LOG("import_abr invalid brush image target: %s", target_paths.status().message);
|
||||
return;
|
||||
}
|
||||
const auto& path_high = target_paths.value().image_path;
|
||||
const auto& path_thumb = target_paths.value().thumbnail_path;
|
||||
auto padded = samp.second->resize_squared(glm::u8vec4(255));
|
||||
//auto high = padded.resize_power2();
|
||||
//high.save(path_high);
|
||||
@@ -987,8 +1014,17 @@ bool NodePanelBrushPreset::import_abr(const std::string& path)
|
||||
auto ii = abr.m_patterns.begin();
|
||||
std::advance(ii, i);
|
||||
const auto& patt = *ii;
|
||||
std::string path_high = App::I->data_path + "/patterns/" + patt.first + ".png";
|
||||
std::string path_thumb = App::I->data_path + "/patterns/thumbs/" + patt.first + ".png";
|
||||
const auto target_paths = pp::assets::plan_brush_package_image_target_paths(
|
||||
App::I->data_path,
|
||||
pp::assets::BrushPackageImageKind::pattern,
|
||||
patt.first,
|
||||
"png");
|
||||
if (!target_paths) {
|
||||
LOG("import_abr invalid pattern image target: %s", target_paths.status().message);
|
||||
return;
|
||||
}
|
||||
const auto& path_high = target_paths.value().image_path;
|
||||
const auto& path_thumb = target_paths.value().thumbnail_path;
|
||||
patt.second->save_png(path_high);
|
||||
auto thumb = patt.second->resize(64, 64);
|
||||
thumb.save_png(path_thumb);
|
||||
|
||||
Reference in New Issue
Block a user