Public Member Functions | Protected Attributes | Friends | List of all members
evd::PNGView Class Reference

#include <PNGArena.h>

Public Member Functions

 PNGView (PNGArena &a)
 
png_byteoperator() (int x, int y, int c)
 
png_byte operator() (int x, int y, int c) const
 

Protected Attributes

PNGArenaarena
 
std::vector< std::vector< png_byte * > > blocks
 

Friends

JSONFormatteroperator<< (JSONFormatter &, const PNGView &)
 

Detailed Description

Definition at line 69 of file PNGArena.h.

Constructor & Destructor Documentation

evd::PNGView::PNGView ( PNGArena a)
explicit

Definition at line 164 of file PNGArena.cxx.

164  : arena(a)
165  {
166  }
const double a
PNGArena & arena
Definition: PNGArena.h:97

Member Function Documentation

png_byte& evd::PNGView::operator() ( int  x,
int  y,
int  c 
)
inline

Definition at line 74 of file PNGArena.h.

75  {
76  const unsigned int ix = x/PNGArena::kBlockSize;
77  const unsigned int iy = y/PNGArena::kBlockSize;
78  if(ix >= blocks.size()) blocks.resize(ix+1);
79  if(iy >= blocks[ix].size()) blocks[ix].resize(iy+1, 0);
80  if(!blocks[ix][iy]) blocks[ix][iy] = arena.NewBlock();
82  }
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
PNGArena & arena
Definition: PNGArena.h:97
std::vector< std::vector< png_byte * > > blocks
Definition: PNGArena.h:99
png_byte * NewBlock()
Definition: PNGArena.cxx:19
list x
Definition: train.py:276
png_byte evd::PNGView::operator() ( int  x,
int  y,
int  c 
) const
inline

Definition at line 84 of file PNGArena.h.

85  {
86  const unsigned int ix = x/PNGArena::kBlockSize;
87  const unsigned int iy = y/PNGArena::kBlockSize;
88  if(ix >= blocks.size()) return 0;
89  if(iy >= blocks[ix].size()) return 0;
90  if(!blocks[ix][iy]) return 0;
92  }
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
std::vector< std::vector< png_byte * > > blocks
Definition: PNGArena.h:99
list x
Definition: train.py:276

Friends And Related Function Documentation

JSONFormatter& operator<< ( JSONFormatter os,
const PNGView v 
)
friend

Definition at line 449 of file WebEVDServer.cxx.

450 {
451  bool first = true;
452  os << "{\"blocks\": [\n";
453  for(unsigned int ix = 0; ix < v.blocks.size(); ++ix){
454  for(unsigned int iy = 0; iy < v.blocks[ix].size(); ++iy){
455  const png_byte* b = v.blocks[ix][iy];
456  if(!b) continue;
457 
458  if(!first) os << ",\n";
459  first = false;
460 
461  int dataidx = 0;
462  for(unsigned int d = 0; d < v.arena.data.size(); ++d){
463  if(b >= &v.arena.data[d]->front() &&
464  b < &v.arena.data[d]->front() + 4*PNGArena::kArenaSize*PNGArena::kArenaSize){
465  dataidx = d;
466  break;
467  }
468  }
469 
470  const int texdx = ((b-&v.arena.data[dataidx]->front())/4)%PNGArena::kArenaSize;
471  const int texdy = ((b-&v.arena.data[dataidx]->front())/4)/PNGArena::kArenaSize;
472 
473  os << "{"
474  << "\"x\": " << ix*PNGArena::kBlockSize << ", "
475  << "\"y\": " << iy*PNGArena::kBlockSize << ", "
476  << "\"dx\": " << PNGArena::kBlockSize << ", "
477  << "\"dy\": " << PNGArena::kBlockSize << ", "
478  << "\"fname\": \"" << v.arena.name << "_" << dataidx << "\", "
479  << "\"texdim\": " << PNGArena::kArenaSize << ", "
480  << "\"u\": " << texdx << ", "
481  << "\"v\": " << texdy << ", "
482  << "\"du\": " << PNGArena::kBlockSize << ", "
483  << "\"dv\": " << PNGArena::kBlockSize
484  << "}";
485  }
486  }
487  os << "\n]}";
488  return os;
489 }
unsigned char png_byte
Definition: PNGArena.h:10
static bool * b
Definition: config.cpp:1043

Member Data Documentation

PNGArena& evd::PNGView::arena
protected

Definition at line 97 of file PNGArena.h.

std::vector<std::vector<png_byte*> > evd::PNGView::blocks
protected

Definition at line 99 of file PNGArena.h.


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