Skip to content

Commit

Permalink
Merge branch 'master' into fork-master
Browse files Browse the repository at this point in the history
  • Loading branch information
oluseyi committed Apr 4, 2020
2 parents a8d92f7 + 4bbd743 commit 8a25ba0
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions src/Samples/PsdSamples.cpp
Expand Up @@ -204,13 +204,31 @@ namespace

// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
int SampleReadPsd(void)
static std::wstring GetSampleInputPath(void)
{
#if PSD_USE_MSVC
const std::wstring srcPath = L"..\\..\\bin\\Sample.psd";
#else
const std::wstring srcPath = L"/Users/oluseyi/Projects/psd_sdk/bin/Sample.psd";
// TODO: add support for other platforms
#ifdef _WIN32
return L"../../bin/";
#endif
}


// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
static std::wstring GetSampleOutputPath(void)
{
// TODO: add support for other platforms
#ifdef _WIN32
return L"../../bin/";
#endif
}


// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
int SampleReadPsd(void)
{
const std::wstring srcPath = GetSampleInputPath() + L"Sample.psd";

MallocAllocator allocator;
NativeFile file(&allocator);
Expand Down Expand Up @@ -355,6 +373,7 @@ int SampleReadPsd(void)
if (document->bitsPerChannel == 8u)
{
std::wstringstream filename;
filename << GetSampleOutputPath();
filename << L"layer";
filename << layerName.str();
filename << L".tga";
Expand All @@ -366,6 +385,7 @@ int SampleReadPsd(void)
if (document->bitsPerChannel == 8u)
{
std::wstringstream filename;
filename << GetSampleOutputPath();
filename << L"layer";
filename << layerName.str();
filename << L".tga";
Expand All @@ -390,6 +410,7 @@ int SampleReadPsd(void)
void* maskData = layer->layerMask->data;
{
std::wstringstream filename;
filename << GetSampleOutputPath();
filename << L"layer";
filename << layerName.str();
filename << L"_usermask.tga";
Expand All @@ -400,6 +421,7 @@ int SampleReadPsd(void)
void* maskCanvasData = ExpandMaskToCanvas(document, &allocator, layer->layerMask);
{
std::wstringstream filename;
filename << GetSampleOutputPath();
filename << L"canvas";
filename << layerName.str();
filename << L"_usermask.tga";
Expand All @@ -418,6 +440,7 @@ int SampleReadPsd(void)
void* maskData = layer->vectorMask->data;
{
std::wstringstream filename;
filename << GetSampleOutputPath();
filename << L"layer";
filename << layerName.str();
filename << L"_vectormask.tga";
Expand All @@ -427,6 +450,7 @@ int SampleReadPsd(void)
void* maskCanvasData = ExpandMaskToCanvas(document, &allocator, layer->vectorMask);
{
std::wstringstream filename;
filename << GetSampleOutputPath();
filename << L"canvas";
filename << layerName.str();
filename << L"_vectormask.tga";
Expand Down Expand Up @@ -516,6 +540,7 @@ int SampleReadPsd(void)
if (document->bitsPerChannel == 8)
{
std::wstringstream filename;
filename << GetSampleOutputPath();
filename << L"merged.tga";
if (isRgb)
{
Expand Down Expand Up @@ -547,6 +572,7 @@ int SampleReadPsd(void)
if (document->bitsPerChannel == 8)
{
std::wstringstream filename;
filename << GetSampleOutputPath();
filename << L"extra_channel_";
filename << channel->asciiName.c_str();
filename << L".tga";
Expand Down Expand Up @@ -577,7 +603,7 @@ int SampleWritePsd(void)
GenerateImageData();

{
const std::wstring dstPath = L"SampleWrite_8.psd";
const std::wstring dstPath = GetSampleOutputPath() + L"SampleWrite_8.psd";

MallocAllocator allocator;
NativeFile file(&allocator);
Expand Down Expand Up @@ -657,7 +683,7 @@ int SampleWritePsd(void)
file.Close();
}
{
const std::wstring dstPath = L"SampleWrite_16.psd";
const std::wstring dstPath = GetSampleOutputPath() + L"SampleWrite_16.psd";

MallocAllocator allocator;
NativeFile file(&allocator);
Expand Down Expand Up @@ -695,7 +721,7 @@ int SampleWritePsd(void)
file.Close();
}
{
const std::wstring dstPath = L"SampleWrite_32.psd";
const std::wstring dstPath = GetSampleOutputPath() + L"SampleWrite_32.psd";

MallocAllocator allocator;
NativeFile file(&allocator);
Expand Down

0 comments on commit 8a25ba0

Please sign in to comment.