00001 #ifndef Impala_Core_Stream_DummyFrameProvider_h
00002 #define Impala_Core_Stream_DummyFrameProvider_h
00003
00004 #include "Core/Array/Arrays.h"
00005 #include "Core/Table/TableTem.h"
00006
00007 namespace Impala
00008 {
00009 namespace Core
00010 {
00011 namespace Stream
00012 {
00013
00014
00018 class DummyFrameProvider
00019 {
00020
00021 public:
00022
00023 static UInt8*
00024 DataPtr(int width, int height)
00025 {
00026 static DummyFrameProvider instance;
00027 return instance.GetDataPtr(width, height);
00028 }
00029
00030 private:
00031
00033 typedef Table::TableTem< Column::ColumnTem<int>,
00034 Column::ColumnTem<int>,
00035 Column::ColumnTem<Array::Array2dVec3UInt8*> > DummyFrameTable;
00036
00038 DummyFrameProvider() : mDummyFrames(DummyFrameTable(1))
00039 {
00040 }
00041
00043 ~DummyFrameProvider()
00044 {
00045 for (int idx = 0; idx < mDummyFrames.Size(); idx++)
00046 {
00047 Array::Array2dVec3UInt8* image = mDummyFrames.Get3(idx);
00048 delete image;
00049 }
00050 }
00051
00052 UInt8*
00053 GetDataPtr(int width, int height)
00054 {
00055 for (int idx = 0 ; idx < mDummyFrames.Size(); idx++)
00056 {
00057 if (mDummyFrames.Get1(idx) == width &&
00058 mDummyFrames.Get2(idx) == height)
00059 {
00060 Array::Array2dVec3UInt8* image = mDummyFrames.Get3(idx);
00061 return image->mData;
00062 }
00063 }
00064
00065 Array::Array2dVec3UInt8* image =
00066 new Array::Array2dVec3UInt8(width, height, 0, 0);
00067 const Array::Element::Vec3Int32 black(0, 0, 0);
00068 for (int x = 0; x < width; x++)
00069 for (int y = 0; y < height; y++)
00070 image->SetValue(black, x, y);
00071 int halfTheWidth = (width + 1) / 2;
00072
00073
00074
00075 const Array::Element::Vec3Int32 contrastColor(255, 255, 0);
00076 double y1 = 0;
00077 double y2 = 0.5;
00078 double yDelta = (height - 1.0) / (width - 1.0);
00079 for (int x = 0; x < halfTheWidth; x++)
00080 {
00081 image->SetValue(contrastColor, x, (int) y1);
00082 image->SetValue(contrastColor, x, (int) y2);
00083
00084 image->SetValue(contrastColor, x, height - 1 - (int) y1);
00085 image->SetValue(contrastColor, x, height - 1 - (int) y2);
00086
00087 image->SetValue(contrastColor, width - 1 - x, (int) y1);
00088 image->SetValue(contrastColor, width - 1 - x, (int) y2);
00089
00090 image->SetValue(contrastColor, width - 1 - x, height - 1 - (int) y1);
00091 image->SetValue(contrastColor, width - 1 - x, height - 1 - (int) y2);
00092
00093 y1 += yDelta;
00094 y2 += yDelta;
00095 }
00096 mDummyFrames.Add(width, height, image);
00097 return image->mData;
00098 }
00099
00100
00101 DummyFrameTable mDummyFrames;
00102
00103 ILOG_VAR_DECL;
00104 };
00105
00106
00107
00108 ILOG_VAR_INIT(DummyFrameProvider, Impala.Core.Stream);
00109
00110 }
00111 }
00112 }
00113
00114 #endif