-/*\r
-* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG (www.casparcg.com).\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-*\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-* Author: Robert Nagy, ronag89@gmail.com\r
-*/\r
-\r
-#include "image_consumer.h"\r
-\r
-#include <common/except.h>\r
-#include <common/env.h>\r
-#include <common/log.h>\r
-#include <common/utf.h>\r
-#include <common/array.h>\r
-\r
-#include <core/consumer/frame_consumer.h>\r
-#include <core/video_format.h>\r
-#include <core/frame/frame.h>\r
-\r
-#include <boost/date_time/posix_time/posix_time.hpp>\r
-#include <boost/thread.hpp>\r
-\r
-#include <tbb/concurrent_queue.h>\r
-\r
-#include <asmlib.h>\r
-\r
-#include <FreeImage.h>\r
-\r
-#include <vector>\r
-\r
-namespace caspar { namespace image {\r
- \r
-struct image_consumer : public core::frame_consumer\r
-{\r
-public:\r
-\r
- // frame_consumer\r
-\r
- void initialize(const core::video_format_desc&, int) override\r
- {\r
- }\r
- \r
- bool send(core::const_frame frame) override\r
- { \r
- boost::thread async([frame]\r
- {\r
- try\r
- {\r
- auto filename = u8(env::data_folder()) + boost::posix_time::to_iso_string(boost::posix_time::second_clock::local_time()) + ".png";\r
-\r
- auto bitmap = std::shared_ptr<FIBITMAP>(FreeImage_Allocate(static_cast<int>(frame.width()), static_cast<int>(frame.height()), 32), FreeImage_Unload);\r
- A_memcpy(FreeImage_GetBits(bitmap.get()), frame.image_data().begin(), frame.image_data().size());\r
- FreeImage_FlipVertical(bitmap.get());\r
- FreeImage_Save(FIF_PNG, bitmap.get(), filename.c_str(), 0);\r
- }\r
- catch(...)\r
- {\r
- CASPAR_LOG_CURRENT_EXCEPTION();\r
- }\r
- });\r
- async.detach();\r
-\r
- return false;\r
- }\r
-\r
- std::wstring print() const override\r
- {\r
- return L"image[]";\r
- }\r
- \r
- std::wstring name() const override\r
- {\r
- return L"image";\r
- }\r
-\r
- boost::property_tree::wptree info() const override\r
- {\r
- boost::property_tree::wptree info;\r
- info.add(L"type", L"image");\r
- return info;\r
- }\r
-\r
- int buffer_depth() const override\r
- {\r
- return 0;\r
- }\r
-\r
- int index() const override\r
- {\r
- return 100;\r
- }\r
-\r
- void subscribe(const monitor::observable::observer_ptr& o) override\r
- {\r
- }\r
-\r
- void unsubscribe(const monitor::observable::observer_ptr& o) override\r
- {\r
- } \r
-};\r
-\r
-spl::shared_ptr<core::frame_consumer> create_consumer(const std::vector<std::wstring>& params)\r
-{\r
- if(params.size() < 1 || params[0] != L"IMAGE")\r
- return core::frame_consumer::empty();\r
-\r
- return spl::make_shared<image_consumer>();\r
-}\r
-\r
-}}\r
+/*
+* 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: Robert Nagy, ronag89@gmail.com
+*/
+
+#include "image_consumer.h"
+
+#include <common/except.h>
+#include <common/env.h>
+#include <common/log.h>
+#include <common/utf.h>
+#include <common/array.h>
+
+#include <core/consumer/frame_consumer.h>
+#include <core/video_format.h>
+#include <core/frame/frame.h>
+
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/thread.hpp>
+
+#include <tbb/concurrent_queue.h>
+
+#include <asmlib.h>
+
+#include <FreeImage.h>
+
+#include <vector>
+
+namespace caspar { namespace image {
+
+struct image_consumer : public core::frame_consumer
+{
+public:
+
+ // frame_consumer
+
+ void initialize(const core::video_format_desc&, int) override
+ {
+ }
+
+ bool send(core::const_frame frame) override
+ {
+ boost::thread async([frame]
+ {
+ try
+ {
+ auto filename = u8(env::data_folder()) + boost::posix_time::to_iso_string(boost::posix_time::second_clock::local_time()) + ".png";
+
+ auto bitmap = std::shared_ptr<FIBITMAP>(FreeImage_Allocate(static_cast<int>(frame.width()), static_cast<int>(frame.height()), 32), FreeImage_Unload);
+ A_memcpy(FreeImage_GetBits(bitmap.get()), frame.image_data().begin(), frame.image_data().size());
+ FreeImage_FlipVertical(bitmap.get());
+ FreeImage_Save(FIF_PNG, bitmap.get(), filename.c_str(), 0);
+ }
+ catch(...)
+ {
+ CASPAR_LOG_CURRENT_EXCEPTION();
+ }
+ });
+ async.detach();
+
+ return false;
+ }
+
+ std::wstring print() const override
+ {
+ return L"image[]";
+ }
+
+ std::wstring name() const override
+ {
+ return L"image";
+ }
+
+ boost::property_tree::wptree info() const override
+ {
+ boost::property_tree::wptree info;
+ info.add(L"type", L"image");
+ return info;
+ }
+
+ int buffer_depth() const override
+ {
+ return 0;
+ }
+
+ int index() const override
+ {
+ return 100;
+ }
+
+ void subscribe(const monitor::observable::observer_ptr& o) override
+ {
+ }
+
+ void unsubscribe(const monitor::observable::observer_ptr& o) override
+ {
+ }
+};
+
+spl::shared_ptr<core::frame_consumer> create_consumer(const std::vector<std::wstring>& params)
+{
+ if(params.size() < 1 || params[0] != L"IMAGE")
+ return core::frame_consumer::empty();
+
+ return spl::make_shared<image_consumer>();
+}
+
+}}