]> git.sesse.net Git - casparcg/blob - server/frame/BitmapFrame.cpp
1.8.1:
[casparcg] / server / frame / BitmapFrame.cpp
1 /*\r
2 * copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
3 *\r
4 *  This file is part of CasparCG.\r
5 *\r
6 *    CasparCG is free software: you can redistribute it and/or modify\r
7 *    it under the terms of the GNU General Public License as published by\r
8 *    the Free Software Foundation, either version 3 of the License, or\r
9 *    (at your option) any later version.\r
10 *\r
11 *    CasparCG is distributed in the hope that it will be useful,\r
12 *    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14 *    GNU General Public License for more details.\r
15 \r
16 *    You should have received a copy of the GNU General Public License\r
17 *    along with CasparCG.  If not, see <http://www.gnu.org/licenses/>.\r
18 *\r
19 */\r
20  \r
21 #include "..\StdAfx.h"\r
22 #include "BitmapFrame.h"\r
23 #include "BitmapFrameManager.h"\r
24 \r
25 namespace caspar{\r
26 \r
27 BitmapFrame::BitmapFrame(BitmapHolderPtr pBitmap, const utils::ID& factoryID)\r
28         : pBitmap_(pBitmap), factoryID_(factoryID)\r
29 {\r
30 }\r
31 \r
32 BitmapFrame::BitmapFrame(const utils::ID& factoryID, HWND hWnd, size_t height, size_t width, void* memory)\r
33         : pBitmap_(new BitmapHolder(hWnd, height, width, memory)), factoryID_(factoryID)\r
34 {\r
35 }\r
36 \r
37 BitmapFrame::~BitmapFrame()\r
38 {\r
39 }\r
40 \r
41 unsigned int BitmapFrame::GetDataSize() const \r
42 {\r
43         return pBitmap_->Size();\r
44 }\r
45 \r
46 unsigned char* BitmapFrame::GetDataPtr() const \r
47 {\r
48         if(pBitmap_ != 0) \r
49         {\r
50                 HasVideo(true);\r
51                 return pBitmap_->GetPtr();\r
52         }\r
53         return 0;\r
54 }\r
55 \r
56 BitmapHolderPtr BitmapFrame::GetBitmap() const\r
57 {\r
58         return pBitmap_;\r
59 }\r
60 \r
61 bool BitmapFrame::HasValidDataPtr() const \r
62 {\r
63         return (pBitmap_ != 0 && pBitmap_->GetPtr() != 0);\r
64 }\r
65 \r
66 FrameMetadata BitmapFrame::GetMetadata() const \r
67 {\r
68         return (pBitmap_ != 0) ? reinterpret_cast<FrameMetadata>(pBitmap_->GetDC()) : 0;\r
69 }\r
70 \r
71 const utils::ID& BitmapFrame::FactoryID() const\r
72 {\r
73         return factoryID_;\r
74 }\r
75 \r
76 HDC BitmapFrame::GetDC() const\r
77 {\r
78         return pBitmap_->GetDC();\r
79 }\r
80 \r
81 }