Scroom 0.14-49-gb7ae7a6d
Loading...
Searching...
No Matches
Scroom::Pnm::AsciiSource1bpp Class Reference

#include <pnmsource.hh>

Inheritance diagram for Scroom::Pnm::AsciiSource1bpp:
Inheritance graph
Collaboration diagram for Scroom::Pnm::AsciiSource1bpp:
Collaboration graph

Public Types

using Ptr = std::shared_ptr< AsciiSource1bpp >
 
- Public Types inherited from Scroom::Pnm::Source
using Ptr = std::shared_ptr< Source >
 
- Public Types inherited from SourcePresentation
using Ptr = std::shared_ptr< SourcePresentation >
 

Public Member Functions

void fillTiles (int startLine, int lineCount, int tileWidth, int firstTile, std::vector< Tile::Ptr > &tiles) override
 
- Public Member Functions inherited from Scroom::Pnm::Source
bool resetPresentation ()
 
void done () override
 
std::string getName () override
 

Static Public Member Functions

static Ptr create (std::string fileName, std::ifstream pnm, BitmapMetaData bmd)
 

Private Member Functions

 Source (std::string fileName, std::ifstream pnm, BitmapMetaData bmd)
 

Additional Inherited Members

- Protected Member Functions inherited from Scroom::Pnm::Source
 Source (std::string fileName, std::ifstream pnm, BitmapMetaData bmd)
 
- Protected Attributes inherited from Scroom::Pnm::Source
std::string m_fileName
 
std::ifstream m_preOpenedPnm
 
std::ifstream m_pnm
 
BitmapMetaData m_bmd
 
Scroom::Logger m_logger
 

Member Typedef Documentation

◆ Ptr

Member Function Documentation

◆ create()

AsciiSource1bpp::Ptr Scroom::Pnm::AsciiSource1bpp::create ( std::string  fileName,
std::ifstream  pnm,
BitmapMetaData  bmd 
)
static
286 {
287 return Ptr(new AsciiSource1bpp(std::move(fileName), std::move(pnm), std::move(bmd)));
288 }
std::shared_ptr< AsciiSource1bpp > Ptr
Definition pnmsource.hh:87

Referenced by Pnm::open().

Here is the caller graph for this function:

◆ fillTiles()

void Scroom::Pnm::AsciiSource1bpp::fillTiles ( int  startLine,
int  lineCount,
int  tileWidth,
int  firstTile,
std::vector< Tile::Ptr > &  tiles 
)
overridevirtual

Provide bitmap data

While the TiledBitmap is loaded, this function will be called several times. Each time, this function has to fill the provided tiles with bitmap data.

The given tiles are horizontally adjacent.

Parameters
startLiney coordinate of the first line in the set of tiles
lineCountThe number of lines that are to be filled. This equals the height of the tiles
tileWidthThe width of one tile
firstTileIndex of the first tile provided. This means that the first x coordinate is firsttile * tileWidth
tilesThe tiles that are to be filled.

Implements SourcePresentation.

291 {
292 const auto firstTile = static_cast<size_t>(firstTile_);
293 const auto tileStride = static_cast<size_t>(tileWidth / 8);
294 const auto width = static_cast<size_t>(m_bmd.rect.width());
295
296 const size_t tileCount = tiles.size();
297 auto dataPtr = std::vector<byte*>(tileCount);
298 for(size_t tile = 0; tile < tileCount; tile++)
299 {
300 dataPtr[tile] = tiles[tile]->data.get();
301 }
302
303 for(size_t i = 0; i < static_cast<size_t>(lineCount); i++)
304 {
305 // Read all pixel values for this row, pack into per-tile byte rows MSB-first
306 for(size_t x = 0; x < width; x++)
307 {
309 char c = '0';
310 m_pnm.get(c);
311 const int value = (c == '1') ? 1 : 0;
312
313 const size_t tileIndex = (firstTile + x / static_cast<size_t>(tileWidth));
314 const size_t localTile = tileIndex - firstTile;
315 const size_t bitPos = x % static_cast<size_t>(tileWidth);
316 if(value != 0)
317 {
318 dataPtr[localTile][bitPos / 8] |= static_cast<byte>(0x80u >> (bitPos % 8));
319 }
320 }
321
322 for(size_t tile = 0; tile < tileCount; tile++)
323 {
324 dataPtr[tile] += tileStride;
325 }
326 }
327 }
const uint8_t value
Definition blob-tests.cc:114
std::ifstream m_pnm
Definition pnmsource.hh:41
BitmapMetaData m_bmd
Definition pnmsource.hh:42
value_type width() const
Definition rectangle.hh:129
void skipComments(std::istream &s)
Definition pnmsource.cc:27
Scroom::Utils::Rectangle< int > rect
Definition opentiledbitmapinterface.hh:47
Semaphore c(0)
Here is the call graph for this function:

◆ Source()

Scroom::Pnm::Source::Source ( std::string  fileName,
std::ifstream  pnm,
BitmapMetaData  bmd 
)
private
151 : m_fileName(std::move(fileName))
152 , m_preOpenedPnm(std::move(pnm))
153 , m_bmd(std::move(bmd))
154 {
155 }
std::ifstream m_preOpenedPnm
Definition pnmsource.hh:40
std::string m_fileName
Definition pnmsource.hh:39

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