Skip to content

Commit

Permalink
dev: Change collage encoder to JPEG.
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmin42 committed Feb 11, 2025
1 parent bb36dda commit 55f0ca0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
6 changes: 3 additions & 3 deletions PB/src/CollageMakerJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ void CollageMakerJob::mapJobs(Path templatePath, std::vector<Path> imagesPaths)

auto resourcePath = mPlatformInfo->projectSupportFolder(mProject->first);

mResourcesProviderId = mResources->addResource(resourcePath);
mResourcesProviderId = mResources->addResource(resourcePath / "thumbnail-images");

std::vector<Path> imagesNames;
for (auto const &imagePath : imagesPaths) {
imagesNames.push_back(imagePath.filename());
imagesNames.push_back(imagePath);
}

std::string newImageName =
boost::uuids::to_string(boost::uuids::random_generator()()) + ".png";
boost::uuids::to_string(boost::uuids::random_generator()()) + ".jpeg";

Path projectThumbnailsRoot =
mPlatformInfo->projectSupportFolder(mProject->first);
Expand Down
2 changes: 1 addition & 1 deletion PB/src/CollageService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void CollageService::combineImages(unsigned templateIndex,
auto templatePaths = mThumbnailsJob->getSourceTemplates();
std::vector<Path> imagesPaths;
for (const auto &image : images) {
imagesPaths.push_back(image->full());
imagesPaths.push_back(Path("thumbnail-images") / image->full());
}
mCollageMakerJob->mapJobs(templatePaths.at(templateIndex).path, imagesPaths);
mCollageMakerStopSource =
Expand Down
6 changes: 4 additions & 2 deletions PB/src/CollageThumbnailsMakerJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ CollageThumbnailsMakerJob::getSourceTemplates() const

void CollageThumbnailsMakerJob::createPlaceholdersFolder()
{
bool success = std::filesystem::create_directories(
mPlatformInfo->collagesFolder(mProject->first));
auto collagesPath = mPlatformInfo->collagesFolder(mProject->first);
bool success = std::filesystem::create_directories(collagesPath);
if (success) {
spdlog::info("[CollageThumbnailsMakerJob] Created placeholders folder for "
"project: {}",
Expand Down Expand Up @@ -156,6 +156,8 @@ void CollageThumbnailsMakerJob::createTemplatesThumbnail(unsigned i)
Path outFilePath = mPlatformInfo->collagesFolder(mProject->first) /
(path.stem().string() + ".png");
if (std::filesystem::exists(outFilePath)) {
auto collageTemplateInfo = parseTemplatePath(outFilePath);
mGeneratedLibraries.push_back(collageTemplateInfo);
return;
}
SkFILEWStream outFile(outFilePath.string().c_str());
Expand Down
10 changes: 6 additions & 4 deletions PB/src/DrawingService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <include/core/SkCanvas.h>
#include <include/core/SkImageInfo.h>
#include <include/core/SkSurface.h>
#include <include/encode/SkPngEncoder.h>
#include <include/encode/SkJpegEncoder.h>
#include <modules/skshaper/utils/FactoryHelpers.h>
#include <modules/svg/include/SkSVGDOM.h>
#pragma warning(pop)
Expand Down Expand Up @@ -69,12 +69,14 @@ void DrawingService::renderToStream(PBDev::SkiaResourcesId resourceId,

image->peekPixels(&pixmap);

SkPngEncoder::Options options;
SkJpegEncoder::Options options;

auto success = SkJpegEncoder::Encode(&outputStream, pixmap, options);
PBDev::basicAssert(success);

SkPngEncoder::Encode(&outputStream, pixmap, options);
outputStream.flush();
}

void DrawingService::renderToBuffer() {}

} // namespace PB
} // namespace PB::Service

0 comments on commit 55f0ca0

Please sign in to comment.