KSquare Utilities
KKB::RasterList Class Reference

#include <Raster.h>

+ Inheritance diagram for KKB::RasterList:

Public Member Functions

 RasterList (bool owner)
 
 RasterList (const RasterList &rasterList, bool _owner)
 
RasterPtr CreateSmoothedFrame ()
 
- Public Member Functions inherited from KKB::KKQueue< Raster >
 KKQueue (bool _owner=true)
 
 KKQueue (const KKQueue &q, bool _owner)
 Constructor, similar to the Copy Constructor except that you can control whether it duplicates the contents. More...
 
virtual ~KKQueue ()
 Virtual destructor; if owns its contents will also call the destructor on each one entry that it contains. More...
 
virtual void Add (EntryPtr _entry)
 
virtual void AddFirst (EntryPtr _entry)
 
virtual void AddQueue (const KKQueue &q)
 Add the contents of a separate KKQueue container to this container. More...
 
EntryPtr BackOfQueue () const
 
void DeleteContents ()
 
void DeleteEntry (EntryPtr _entry)
 
void DeleteEntry (kkuint32 _idx)
 
KKQueueDuplicateListAndContents () const
 Creates a new container including duplicating the contents, which also makes the new instance the owner of those contents. More...
 
kkuint32 FindTheKthElement (kkuint32 k, Functor pred)
 
EntryPtr FrontOfQueue () const
 
EntryPtr GetFirst () const
 
EntryPtr GetLast () const
 
EntryPtr IdxToPtr (kkuint32 idx) const
 
kkint32 LocateEntry (EntryConstPtr _entry) const
 
EntryPtr LookAtBack () const
 
EntryPtr LookAtFront () const
 
bool operator!= (const KKQueue< Raster > &rightSide) const
 returns False if NOT every entry in both containers point to the same elements More...
 
KKQueueoperator= (const KKQueue &q)
 Assignment Operator. More...
 
bool operator== (const KKQueue< Raster > &rightSide) const
 Returns True if every entry in both containers point to the same elements. More...
 
Rasteroperator[] (kkuint32 i) const
 
bool Owner () const
 
void Owner (bool _owner)
 
virtual EntryPtr PopFromBack ()
 
virtual EntryPtr PopFromFront ()
 
kkint32 PtrToIdx (EntryConstPtr _entry) const
 
virtual void PushOnBack (EntryPtr _entry)
 
virtual void PushOnFront (EntryPtr _entry)
 
kkint32 QueueSize () const
 
void RandomizeOrder ()
 Randomizes the order of the vector. More...
 
void RandomizeOrder (kkint64 seed)
 
void RandomizeOrder (RandomNumGenerator &randomVariable)
 Randomizes the order of the vector. More...
 
virtual EntryPtr RemoveFirst ()
 
virtual EntryPtr RemoveLast ()
 
void SetIdxToPtr (kkuint32 _idx, Raster *_ptr)
 
void SwapIndexes (size_t idx1, size_t idx2)
 

Additional Inherited Members

- Public Types inherited from KKB::KKQueue< Raster >
typedef std::vector< Raster * >::const_iterator const_iterator
 
typedef std::vector< Raster * >::iterator iterator
 
- Protected Member Functions inherited from KKB::KKQueue< Raster >
 KKQueue (const KKQueue &q)
 Copy Constructor creating new instance; including duplicating contents if owner set to true. More...
 

Detailed Description

Definition at line 1387 of file Raster.h.

Constructor & Destructor Documentation

KKB::RasterList::RasterList ( bool  owner)
inline

Definition at line 1390 of file Raster.h.

References RasterList().

Referenced by RasterList(), and KKB::Raster::SplitImageIntoEqualParts().

1390  :
1391  KKQueue<Raster> (owner)
1392  {}
KKB::RasterList::RasterList ( const RasterList rasterList,
bool  _owner 
)
inline

Definition at line 1400 of file Raster.h.

References RasterList().

Referenced by RasterList().

1402  :
1403  KKQueue<Raster> (rasterList, _owner)
1404  {}

Member Function Documentation

RasterPtr RasterList::CreateSmoothedFrame ( )

Definition at line 8950 of file Raster.cpp.

References KKB::Raster::AllocateARasterInstance(), KKB::Raster::BlueArea(), KKB::Raster::Color(), KKB::Raster::GreenArea(), KKB::Raster::Height(), KKB::Raster::RedArea(), and KKB::Raster::Width().

8951 {
8952  if (QueueSize () < 1)
8953  return NULL;
8954 
8955  kkint32 x;
8956 
8957  RasterPtr firstRaster = IdxToPtr (0);
8958  kkint32 height = firstRaster->Height ();
8959  kkint32 width = firstRaster->Height ();
8960  kkint32 totPixels = height * width;
8961 
8962  kkuint32* totGreenArea = new kkuint32[totPixels];
8963  memset (totGreenArea, 0, totPixels * sizeof (kkuint32));
8964 
8965  kkint32 idx = 0;
8966  kkint32 rastersAdded = 0;
8967 
8968  for (idx = 0; idx < QueueSize (); idx++)
8969  {
8970  RasterPtr raster = IdxToPtr (idx);
8971  if ((raster->Height () != height) ||
8972  (raster->Width () != width)
8973  )
8974  {
8975  continue;
8976  }
8977 
8978  if (raster->Color ())
8979  {
8980  uchar* redArea = raster->RedArea ();
8981  uchar* greenArea = raster->GreenArea ();
8982  uchar* blueArea = raster->BlueArea ();
8983  for (x = 0; x < totPixels; x++)
8984  {
8985  totGreenArea[x] += (kkuint32)((float)redArea[x] * 0.39f +
8986  (float)greenArea[x] * 0.59f +
8987  (float)blueArea[x] * 0.11f +
8988  0.5f
8989  );
8990  }
8991  }
8992  else
8993  {
8994  uchar* greenArea = raster->GreenArea ();
8995  for (x = 0; x < totPixels; x++)
8996  totGreenArea[x] += greenArea[x];
8997  }
8998 
8999  rastersAdded++;
9000  }
9001 
9002  RasterPtr smoothedRaster = firstRaster->AllocateARasterInstance (height, width, false);
9003 
9004  uchar* newGreenArea = smoothedRaster->GreenArea ();
9005  for (x = 0; x < totPixels; x++)
9006  newGreenArea[x] = (uchar) (totGreenArea[x] / rastersAdded);
9007 
9008  delete[] totGreenArea;
9009 
9010  return smoothedRaster;
9011 } /* CreateSmoothedFrame */
__int32 kkint32
Definition: KKBaseTypes.h:88
virtual RasterPtr AllocateARasterInstance(kkint32 height, kkint32 width, bool color) const
Definition: Raster.cpp:1014
A class that is used by to represent a single image in memory.
Definition: Raster.h:108
EntryPtr IdxToPtr(kkuint32 idx) const
bool Color() const
Definition: Raster.h:310
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
kkint32 Height() const
Definition: Raster.h:319
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
uchar * RedArea() const
Definition: Raster.h:329
uchar * GreenArea() const
Definition: Raster.h:330
uchar * BlueArea() const
Definition: Raster.h:331
kkint32 Width() const
Definition: Raster.h:324
kkint32 QueueSize() const

The documentation for this class was generated from the following files: