{
return layers_;
}
- unsigned long width()
+ unsigned long width() const
{
return width_;
}
- unsigned long height()
+ unsigned long height() const
{
return height_;
}
+ psd::color_mode color_mode() const
+ {
+ return color_mode_;
+ }
+
+ unsigned short color_depth() const
+ {
+ return depth_;
+ }
+ unsigned short channels_count() const
+ {
+ return channels_;
+ }
+ const std::wstring& filename() const
+ {
+ return filename_;
+ }
+
+
bool parse(const std::wstring& s);
private:
unsigned long width_;
unsigned long height_;
unsigned short depth_;
- color_mode color_mode_;
+ psd::color_mode color_mode_;
};
} //namespace psd
//determine target bitmap and offset
if((*it)->id() >= 3)
discard_channel = true; //discard channels that doesn't contribute to the final image
- else if((*it)->id() >= -1) //RGBA-data
+ else if((*it)->id() >= -1) //BGRA-data
{
target = img;
offset = ((*it)->id() >= 0) ? 2 - (*it)->id() : 3;
}
else if(mask) //mask
{
- if((*it)->id() == -2 && masks_ == 2) //if there are two mask-channels, discard the the one that's not the total mask for now
+ if((*it)->id() == -2 && masks_ == 2) //if there are two mask-channels, discard the the one that's not the total mask
discard_channel = true;
else
{
}
}
- unsigned long cp = stream.current_position(); //TODO: remove, for debug purposes only
+ //unsigned long cp = stream.current_position(); //for debug purposes only
//std::clog << std::dec << "channel_id: " << (*it)->id() << ", reading data from: " << std::hex << cp << ", data_length: " << (*it)->data_length() << std::endl;
if(!target)
}
}
-//
-//image_ptr Layer::read_image(BEFileInputStream& stream)
-//{
-// if(image == NULL)
-// {
-// unsigned char channels = (channels_.size() > 3) ? 4 : 3;
-//
-// image = std::make_shared<Image>(static_cast<unsigned short>(rect_.width()), static_cast<unsigned short>(rect_.height()), channels);
-//
-// channel_ptr pChannel = get_channel(ColorRed);
-// if(pChannel != NULL)
-// pChannel->GetChannelImageData(stream, image, 0);
-//
-// pChannel = get_channel(ColorGreen);
-// if(pChannel != NULL)
-// pChannel->GetChannelImageData(stream, image, 1);
-//
-// pChannel = get_channel(ColorBlue);
-// if(pChannel != NULL)
-// pChannel->GetChannelImageData(stream, image, 2);
-//
-// pChannel = get_channel(Transparency);
-// if(channels == 4 && pChannel != NULL)
-// pChannel->GetChannelImageData(stream, image, 3);
-// }
-//
-// return image;
-//}
-
} //namespace psd
} //namespace caspar
\ No newline at end of file
--- /dev/null
+/*
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
+*
+* This file is part of CasparCG (www.casparcg.com).
+*
+* CasparCG is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* CasparCG is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
+*
+* Author: Niklas P Andersson, niklas.p.andersson@svt.se
+*/
+
+#include "psd.h"
+#include "layer.h"
+#include "doc.h"
+
+#include <core/frame/pixel_format.h>
+#include <core/frame/frame_factory.h>
+#include <core/producer/frame_producer.h>
+#include <core/producer/scene/scene_producer.h>
+#include <core/producer/scene/const_producer.h>
+#include <core/frame/draw_frame.h>
+
+#include <common/env.h>
+
+#include <boost/filesystem.hpp>
+
+namespace caspar { namespace psd {
+
+void init()
+{
+ core::register_producer_factory(create_producer);
+}
+
+spl::shared_ptr<core::frame_producer> create_producer(const spl::shared_ptr<core::frame_factory>& frame_factory, const core::video_format_desc& format_desc, const std::vector<std::wstring>& params)
+{
+ std::wstring filename = env::media_folder() + L"\\" + params[0] + L".psd";
+ if(!boost::filesystem::is_regular_file(boost::filesystem::path(filename)))
+ return core::frame_producer::empty();
+
+ psd_document doc;
+ if(!doc.parse(filename))
+ return core::frame_producer::empty();
+
+ spl::shared_ptr<core::scene::scene_producer> root(spl::make_shared<core::scene::scene_producer>(doc.width(), doc.height()));
+
+ auto layers_end = doc.layers().end();
+ int cnt = 0;
+ for(auto it = doc.layers().begin(); it != layers_end; ++it)
+ {
+ if((*it)->image())
+ {
+ core::pixel_format_desc pfd(core::pixel_format::bgra);
+ pfd.planes.push_back(core::pixel_format_desc::plane((*it)->rect().width(), (*it)->rect().height(), 4));
+
+ auto frame = frame_factory->create_frame(it->get(), pfd);
+ memcpy(frame.image_data().data(), (*it)->image()->data(), frame.image_data().size());
+
+ auto layer_producer = core::create_const_producer(core::draw_frame(std::move(frame)), (*it)->rect().width(), (*it)->rect().height());
+ root->create_layer(layer_producer, (*it)->rect().left, (*it)->rect().top);
+ }
+ }
+
+ return root;
+// return spl::make_shared<scene_producer>(frame_factory, filename + *ext);
+}
+
+}}
\ No newline at end of file
--- /dev/null
+/*
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
+*
+* This file is part of CasparCG (www.casparcg.com).
+*
+* CasparCG is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* CasparCG is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
+*
+* Author: Niklas P Andersson, niklas.p.andersson@svt.se
+*/
+
+#pragma once
+
+#include <core/producer/frame_producer.h>
+
+#include <string>
+#include <vector>
+#include <common/memory.h>
+
+namespace caspar { namespace psd {
+
+void init();
+
+spl::shared_ptr<core::frame_producer> create_producer(const spl::shared_ptr<core::frame_factory>& frame_factory, const core::video_format_desc& format_desc, const std::vector<std::wstring>& params);
+
+}}
\ No newline at end of file
#include "stdafx.h"
#include "../../modules/psd/doc.h"
+#include <sstream>
int _tmain(int argc, _TCHAR* argv[])
{
- caspar::psd::Document doc;
+ caspar::psd::psd_document doc;
doc.parse(L"C:\\Lokala Filer\\Utveckling\\CasparCG\\Server 2.1\\test\\data\\test1.psd");
+
+ std::wstringstream trace;
+
+ trace << L"<doc filename=\"" << doc.filename() << L"\" channel_count=\"" << doc.channels_count() << L"\" width=\"" << doc.width() << "\"
int a = 42;
return 0;
}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="ReadMe.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="stdafx.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="targetver.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="stdafx.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="psd-test.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project>
\ No newline at end of file