Scroom 0.14-48-ga0fee447
Loading...
Searching...
No Matches
Scroom::TiledBitmap Namespace Reference

Namespaces

namespace  anonymous_namespace{layerspecforbitmap.cc}
 

Classes

struct  BitmapMetaData
 
class  LayerSpecForBitmapper
 
class  OpenTiledBitmapInterface
 

Typedefs

using ReloadFunction = std::function< Scroom::Utils::Stuff(const ProgressInterface::Ptr &)>
 
using LayerSpecResult = std::tuple< LayerSpec, ColormapHelperBase::Ptr >
 
using LayerSpecForBitmapFunc = std::function< LayerSpecResult(const Scroom::Logger &logger, const BitmapMetaData &bitmapMetaData)>
 

Functions

std::ostream & to_stream (std::ostream &os, const BitmapMetaData &bmd)
 
std::string to_string (const BitmapMetaData &bmd)
 
Metadata::Metadata to_metadata (const BitmapMetaData &bmd)
 
OpenPresentationInterface::Ptr ToOpenPresentationInterface (OpenTiledBitmapInterface::Ptr openTiledBitmapInterface)
 
LayerSpecResult LayerSpecForBitmap (const BitmapMetaData &bitmapMetaData)
 
Scroom::Utils::Stuff scheduleLoadingBitmap (const SourcePresentation::Ptr &sp, const Layer::Ptr &layer, const ProgressInterface::Ptr &progress)
 
LayerSpecResult RGBBitmap (const Scroom::Logger &logger, const BitmapMetaData &bmd)
 
LayerSpecResult CMYKBitmap (const Scroom::Logger &logger, const BitmapMetaData &bmd)
 
LayerSpecResult GreyscaleBitmap (const Scroom::Logger &logger, const BitmapMetaData &bmd)
 
LayerSpecResult ColormappedBitmap (const Scroom::Logger &logger, const BitmapMetaData &bmd)
 

Variables

const std::string RGB = "RGB"
 
const std::string CMYK = "CMYK"
 
const std::string Greyscale = "Greyscale"
 
const std::string Colormapped = "Colormapped"
 

Typedef Documentation

◆ LayerSpecForBitmapFunc

using Scroom::TiledBitmap::LayerSpecForBitmapFunc = typedef std::function<LayerSpecResult(const Scroom::Logger& logger, const BitmapMetaData& bitmapMetaData)>

◆ LayerSpecResult

◆ ReloadFunction

Function type for starting the loading of the bottom Layer of a bitmap.

This function is called on the UI thread. You cannot do a significant amount of work in this function, or you'll block the UI. Typical implementations will schedule work on the Sequentially() ThreadPool, such that bitmaps will be loaded sequentially.

Parameters
progressInterfacecall setProgress(0) on this once the work actually starts
Returns
a shared pointer. Typically a ThreadPool::Queue or similar. The expectation is that when this object is destroyed by the caller, the loading is cancelled.
See also
Layer
OpenTiledBitmapInterface::open()
Sequentially()
scheduleLoadingBitmap() for an example implementation

Function Documentation

◆ CMYKBitmap()

LayerSpecResult Scroom::TiledBitmap::CMYKBitmap ( const Scroom::Logger logger,
const BitmapMetaData bmd 
)
126 {
127 if(bmd.type != CMYK)
128 {
129 return {};
130 }
131
132 require(bmd.samplesPerPixel == 4);
134
135 LayerSpec ls;
136
137 if(bmd.bitsPerSample == 8)
138 {
139 ls.emplace_back(OperationsCMYK32::create());
140 }
141 else if(bmd.bitsPerSample == 4)
142 {
143 ls.emplace_back(OperationsCMYK16::create());
144 ls.emplace_back(OperationsCMYK32::create());
145 }
146 else if(bmd.bitsPerSample == 2)
147 {
148 ls.emplace_back(OperationsCMYK8::create());
149 ls.emplace_back(OperationsCMYK32::create());
150 }
151 else if(bmd.bitsPerSample == 1)
152 {
153 ls.emplace_back(OperationsCMYK4::create());
154 ls.emplace_back(OperationsCMYK32::create());
155 }
156 else
157 {
158 logger->error("CMYK bitmaps with {} bits per sample are not supported", bmd.bitsPerSample);
159 return {};
160 }
161
162 return LayerSpecResult(ls, nullptr);
163 }
#define require(expr)
Definition assertions.hh:30
static Ptr create()
Definition cmyklayeroperations.cc:116
static Ptr create()
Definition cmyklayeroperations.cc:23
static Ptr create()
Definition cmyklayeroperations.cc:299
static Ptr create()
Definition cmyklayeroperations.cc:209
std::tuple< LayerSpec, ColormapHelperBase::Ptr > LayerSpecResult
Definition opentiledbitmapinterface.hh:76
Scroom::Logger logger
Definition callbacks.cc:54
std::string type
Definition opentiledbitmapinterface.hh:44
ColormapHelperBase::Ptr colormapHelper
Definition opentiledbitmapinterface.hh:49
unsigned int bitsPerSample
Definition opentiledbitmapinterface.hh:45
unsigned int samplesPerPixel
Definition opentiledbitmapinterface.hh:46
std::vector< LayerOperations::Ptr > LayerSpec
Definition tiledbitmapinterface.hh:183

Referenced by Scroom::TiledBitmap::LayerSpecForBitmapper::LayerSpecForBitmapper().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ColormappedBitmap()

LayerSpecResult Scroom::TiledBitmap::ColormappedBitmap ( const Scroom::Logger logger,
const BitmapMetaData bmd 
)
205 {
206 if(bmd.type != Colormapped)
207 {
208 return {};
209 }
210 require(bmd.samplesPerPixel == 1);
212
213 if(bmd.bitsPerSample != 1 && bmd.bitsPerSample != 2 && bmd.bitsPerSample != 4 && bmd.bitsPerSample != 8)
214 {
215 logger->error("Colormapped bitmaps with {} bits per pixel are not supported (yet)", bmd.bitsPerSample);
216 return {};
217 }
218
219 LayerSpec ls;
220 ls.push_back(Operations::create(bmd.colormapHelper, bmd.bitsPerSample));
222
223 return LayerSpecResult(ls, bmd.colormapHelper);
224 }
static Ptr create(ColormapProvider::Ptr colormapProvider, int bpp)
Definition layeroperations.cc:731
static Ptr create(ColormapProvider::Ptr colormapProvider, int bpp)
Definition layeroperations.cc:579

Referenced by Scroom::TiledBitmap::LayerSpecForBitmapper::LayerSpecForBitmapper().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GreyscaleBitmap()

LayerSpecResult Scroom::TiledBitmap::GreyscaleBitmap ( const Scroom::Logger logger,
const BitmapMetaData bmd 
)
166 {
167 if(bmd.type != Greyscale)
168 {
169 return {};
170 }
171
172 require(bmd.samplesPerPixel == 1);
173
174 if(bmd.bitsPerSample != 1 && bmd.bitsPerSample != 2 && bmd.bitsPerSample != 4 && bmd.bitsPerSample != 8)
175 {
176 logger->error("Greyscale bitmaps with {} bits per pixel are not supported (yet)", bmd.bitsPerSample);
177 return {};
178 }
179
180 LayerSpec ls;
181 ColormapHelperBase::Ptr colormapHelper = bmd.colormapHelper;
182 if(!colormapHelper)
183 {
184 colormapHelper = MonochromeColormapHelper::create(2);
185 }
186
187 if(bmd.bitsPerSample == 2 || bmd.bitsPerSample == 4)
188 {
189 ls.push_back(Operations::create(colormapHelper, bmd.bitsPerSample));
190 ls.push_back(OperationsColormapped::create(colormapHelper, bmd.bitsPerSample));
191 }
192 else
193 {
194 if(bmd.bitsPerSample == 1)
195 {
196 ls.push_back(Operations1bpp::create(colormapHelper));
197 }
198 ls.push_back(Operations8bpp::create(colormapHelper));
199 }
200
201 return LayerSpecResult(ls, colormapHelper);
202 }
std::shared_ptr< ColormapHelperBase > Ptr
Definition colormappable.hh:158
static Ptr create(int numberOfColors)
Definition colormap-helpers.cc:68
static Ptr create(ColormapProvider::Ptr colormapProvider)
Definition layeroperations.cc:262
static Ptr create(ColormapProvider::Ptr colormapProvider)
Definition layeroperations.cc:381

Referenced by Scroom::TiledBitmap::LayerSpecForBitmapper::LayerSpecForBitmapper().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LayerSpecForBitmap()

LayerSpecResult Scroom::TiledBitmap::LayerSpecForBitmap ( const BitmapMetaData bitmapMetaData)
228 {
229 return LayerSpecForBitmapper::instance()->get(bitmapMetaData);
230 }

Referenced by anonymous_namespace{tiledbitmappresentation.cc}::OpenTiledBitmapAsPresentation::open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RGBBitmap()

LayerSpecResult Scroom::TiledBitmap::RGBBitmap ( const Scroom::Logger logger,
const BitmapMetaData bmd 
)
107 {
108 if(bmd.type != RGB)
109 {
110 return {};
111 };
112
113 require(bmd.samplesPerPixel == 3);
115
116 if(bmd.bitsPerSample != 8)
117 {
118 logger->error("RGB bitmaps with {} bits per sample are not supported", bmd.bitsPerSample);
119 return {};
120 }
121
122 return LayerSpecResult({Operations24bpp::create()}, nullptr);
123 }
static Ptr create()
Definition layeroperations.cc:503

Referenced by Scroom::TiledBitmap::LayerSpecForBitmapper::LayerSpecForBitmapper().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scheduleLoadingBitmap()

Scroom::Utils::Stuff Scroom::TiledBitmap::scheduleLoadingBitmap ( const SourcePresentation::Ptr sp,
const Layer::Ptr layer,
const ProgressInterface::Ptr progress 
)
37{
38 auto wait_until_done = std::make_shared<Scroom::Semaphore>();
39 auto queue = ThreadPool::Queue::createAsync();
40 auto weakQueue = queue->getWeak();
41 auto abort = [wait_until_done, queue]() mutable
42 {
43 queue.reset();
44 wait_until_done->V();
45 };
46
47 auto on_finished = [wait_until_done] { wait_until_done->V(); };
48 progress->setWaiting();
49
50 Sequentially()->schedule(
51 [progress, layer, sp, weakQueue, on_finished, wait_until_done]
52 {
53 Scroom::GtkHelpers::sync_on_ui_thread([=] { progress->setWorking(0); });
54 layer->fetchData(sp, weakQueue, on_finished);
55 wait_until_done->P();
56 }
57 );
58
60}
static Ptr createAsync()
Definition threadpoolimpl.cc:382
void sync_on_ui_thread(T f)
Definition gtk-helpers.hh:59
std::shared_ptr< void > on_destruction(F f)
Definition utilities.hh:84
stub progress
Definition progressinterfaceconversion-tests.cc:65
ThreadPool::Queue::WeakPtr const weakQueue
Definition threadpool-queue-tests.cc:48
ThreadPool::Ptr Sequentially()
Definition threadpoolimpl.cc:462

Referenced by Pnm::open(), Tiff::open(), and TiledBitmap::setSource().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_metadata()

Metadata::Metadata Scroom::TiledBitmap::to_metadata ( const BitmapMetaData bmd)
36 {
38 std::string aspect_ratio_text = fmt::format("{:.2f} : {:.2f}", aspectRatio.x, aspectRatio.y);
39
40 return {
41 {"Color representation", bmd.type},
42 {"Samples per pixel", std::to_string(bmd.samplesPerPixel)},
43 {"Bits per sample", std::to_string(bmd.bitsPerSample)},
44 {"Aspect ratio", aspect_ratio_text},
45 {"Width", std::to_string(bmd.rect.getWidth())},
46 {"Height", std::to_string(bmd.rect.getHeight())},
47 };
48 }
Definition point.hh:28
value_type y
Definition point.hh:112
value_type x
Definition point.hh:111
value_type getWidth() const
Definition rectangle.hh:121
value_type getHeight() const
Definition rectangle.hh:123
boost::optional< Scroom::Utils::Point< double > > aspectRatio
Definition opentiledbitmapinterface.hh:48
Scroom::Utils::Rectangle< int > rect
Definition opentiledbitmapinterface.hh:47

Referenced by anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::showMetadata().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_stream()

std::ostream & Scroom::TiledBitmap::to_stream ( std::ostream &  os,
const BitmapMetaData bmd 
)
21 {
22 os << "Type=\"" << bmd.type << "\", rect=" << bmd.rect << ", spp=" << bmd.samplesPerPixel << ", bps=" << bmd.bitsPerSample
23 << ", colormapped=" << to_string(static_cast<bool>(bmd.colormapHelper));
24
25 return os;
26 }
std::string to_string(const BitmapMetaData &bmd)
Definition layerspecforbitmap.cc:28

Referenced by to_string().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_string()

std::string Scroom::TiledBitmap::to_string ( const BitmapMetaData bmd)
29 {
30 std::stringstream ss;
31 to_stream(ss, bmd);
32 return ss.str();
33 }
std::ostream & to_stream(std::ostream &os, const BitmapMetaData &bmd)
Definition layerspecforbitmap.cc:20

Referenced by Scroom::Tiff::Source::reset(), Scroom::Pnm::Source::resetPresentation(), and to_stream().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToOpenPresentationInterface()

OpenPresentationInterface::Ptr Scroom::TiledBitmap::ToOpenPresentationInterface ( OpenTiledBitmapInterface::Ptr  openTiledBitmapInterface)
443 {
444 return OpenTiledBitmapAsPresentation::create(std::move(openTiledBitmapInterface));
445 }
static Ptr create(OpenTiledBitmapInterface::Ptr openTiledBitmapInterface_)
Definition tiledbitmappresentation.cc:378
Here is the call graph for this function:

Variable Documentation

◆ CMYK

const std::string Scroom::TiledBitmap::CMYK = "CMYK"

Referenced by CMYKBitmap(), and Scroom::Tiff::open().

◆ Colormapped

const std::string Scroom::TiledBitmap::Colormapped = "Colormapped"

◆ Greyscale

const std::string Scroom::TiledBitmap::Greyscale = "Greyscale"

◆ RGB

const std::string Scroom::TiledBitmap::RGB = "RGB"