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

#include <pnmsource.hh>

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

Public Types

using Ptr = std::shared_ptr< BinarySource >
 
- 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

using Scroom::Pnm::BinarySource::Ptr = std::shared_ptr<BinarySource>

Member Function Documentation

◆ create()

BinarySource::Ptr Scroom::Pnm::BinarySource::create ( std::string  fileName,
std::ifstream  pnm,
BitmapMetaData  bmd 
)
static
192 {
193 return Ptr(new BinarySource(std::move(fileName), std::move(pnm), std::move(bmd)));
194 }
std::shared_ptr< BinarySource > Ptr
Definition pnmsource.hh:59

Referenced by Pnm::open().

Here is the caller graph for this function:

◆ fillTiles()

void Scroom::Pnm::BinarySource::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.

197 {
198 auto spp = m_bmd.samplesPerPixel;
199 auto bps = m_bmd.bitsPerSample;
200
201 const auto firstTile = static_cast<size_t>(firstTile_);
202 const auto scanLineSize = static_cast<std::streamsize>((m_bmd.rect.width() * spp * bps + 7) / 8);
203 const auto tileStride = static_cast<size_t>(tileWidth * spp * bps / 8);
204 std::vector<char> row(scanLineSize);
205
206 const size_t tileCount = tiles.size();
207 auto dataPtr = std::vector<byte*>(tileCount);
208 for(size_t tile = 0; tile < tileCount; tile++)
209 {
210 dataPtr[tile] = tiles[tile]->data.get();
211 }
212
213 for(size_t i = 0; i < static_cast<size_t>(lineCount); i++)
214 {
215 m_pnm.read(row.data(), scanLineSize);
216
217 for(size_t tile = 0; tile < tileCount - 1; tile++)
218 {
219 memcpy(dataPtr[tile], row.data() + (firstTile + tile) * tileStride, tileStride);
220 dataPtr[tile] += tileStride;
221 }
222 memcpy(
223 dataPtr[tileCount - 1],
224 row.data() + (firstTile + tileCount - 1) * tileStride,
225 scanLineSize - (firstTile + tileCount - 1) * tileStride
226 );
227 dataPtr[tileCount - 1] += tileStride;
228 }
229 }
std::ifstream m_pnm
Definition pnmsource.hh:41
BitmapMetaData m_bmd
Definition pnmsource.hh:42
value_type width() const
Definition rectangle.hh:129
unsigned int bitsPerSample
Definition opentiledbitmapinterface.hh:45
unsigned int samplesPerPixel
Definition opentiledbitmapinterface.hh:46
Scroom::Utils::Rectangle< int > rect
Definition opentiledbitmapinterface.hh:47
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: