Scroom  0.14
Scroom::TiledBitmap Namespace Reference

Namespaces

 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 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 BitmapMetaData &bmd)
 
LayerSpecResult CMYKBitmap (const BitmapMetaData &bmd)
 
LayerSpecResult GreyscaleBitmap (const BitmapMetaData &bmd)
 
LayerSpecResult ColormappedBitmap (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 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 BitmapMetaData bmd)
127  {
128  if(bmd.type != CMYK)
129  {
130  return {};
131  }
132 
133  require(bmd.samplesPerPixel == 4);
134  require(!bmd.colormapHelper);
135 
136  LayerSpec ls;
137 
138  if(bmd.bitsPerSample == 8)
139  {
140  ls.emplace_back(OperationsCMYK32::create());
141  }
142  else if(bmd.bitsPerSample == 4)
143  {
144  ls.emplace_back(OperationsCMYK16::create());
145  ls.emplace_back(OperationsCMYK32::create());
146  }
147  else if(bmd.bitsPerSample == 2)
148  {
149  ls.emplace_back(OperationsCMYK8::create());
150  ls.emplace_back(OperationsCMYK32::create());
151  }
152  else if(bmd.bitsPerSample == 1)
153  {
154  ls.emplace_back(OperationsCMYK4::create());
155  ls.emplace_back(OperationsCMYK32::create());
156  }
157  else
158  {
159  spdlog::error("CMYK bitmaps with {} bits per sample are not supported", bmd.bitsPerSample);
160  return {};
161  }
162 
163  return LayerSpecResult(ls, nullptr);
164  }

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 BitmapMetaData bmd)
206  {
207  if(bmd.type != Colormapped)
208  {
209  return {};
210  }
211  require(bmd.samplesPerPixel == 1);
212  require(bmd.colormapHelper);
213 
214  if(bmd.bitsPerSample != 1 && bmd.bitsPerSample != 2 && bmd.bitsPerSample != 4 && bmd.bitsPerSample != 8)
215  {
216  spdlog::error("Colormapped bitmaps with {} bits per pixel are not supported (yet)", bmd.bitsPerSample);
217  return {};
218  }
219 
220  LayerSpec ls;
221  ls.push_back(Operations::create(bmd.colormapHelper, bmd.bitsPerSample));
222  ls.push_back(OperationsColormapped::create(bmd.colormapHelper, bmd.bitsPerSample));
223 
224  return LayerSpecResult(ls, bmd.colormapHelper);
225  }

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 BitmapMetaData bmd)
167  {
168  if(bmd.type != Greyscale)
169  {
170  return {};
171  }
172 
173  require(bmd.samplesPerPixel == 1);
174 
175  if(bmd.bitsPerSample != 1 && bmd.bitsPerSample != 2 && bmd.bitsPerSample != 4 && bmd.bitsPerSample != 8)
176  {
177  spdlog::error("Greyscale bitmaps with {} bits per pixel are not supported (yet)", bmd.bitsPerSample);
178  return {};
179  }
180 
181  LayerSpec ls;
182  ColormapHelperBase::Ptr colormapHelper = bmd.colormapHelper;
183  if(!colormapHelper)
184  {
185  colormapHelper = MonochromeColormapHelper::create(2);
186  }
187 
188  if(bmd.bitsPerSample == 2 || bmd.bitsPerSample == 4)
189  {
190  ls.push_back(Operations::create(colormapHelper, bmd.bitsPerSample));
191  ls.push_back(OperationsColormapped::create(colormapHelper, bmd.bitsPerSample));
192  }
193  else
194  {
195  if(bmd.bitsPerSample == 1)
196  {
197  ls.push_back(Operations1bpp::create(colormapHelper));
198  }
199  ls.push_back(Operations8bpp::create(colormapHelper));
200  }
201 
202  return LayerSpecResult(ls, colormapHelper);
203  }

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)
229  {
230  return LayerSpecForBitmapper::instance()->get(bitmapMetaData);
231  }

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 BitmapMetaData bmd)
108  {
109  if(bmd.type != RGB)
110  {
111  return {};
112  };
113 
114  require(bmd.samplesPerPixel == 3);
115  require(!bmd.colormapHelper);
116 
117  if(bmd.bitsPerSample != 8)
118  {
119  spdlog::error("RGB bitmaps with {} bits per sample are not supported", bmd.bitsPerSample);
120  return {};
121  }
122 
123  return LayerSpecResult({Operations24bpp::create()}, nullptr);
124  }

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 
)
36 {
37  auto wait_until_done = boost::make_shared<Scroom::Semaphore>();
38  auto queue = ThreadPool::Queue::createAsync();
39  auto weakQueue = queue->getWeak();
40  auto abort = [wait_until_done, queue]() mutable
41  {
42  queue.reset();
43  wait_until_done->V();
44  };
45 
46  auto on_finished = [wait_until_done] { wait_until_done->V(); };
47  progress->setWaiting();
48 
49  Sequentially()->schedule(
50  [progress, layer, sp, weakQueue, on_finished, wait_until_done]
51  {
52  Scroom::GtkHelpers::sync_on_ui_thread([=] { progress->setWorking(0); });
53  layer->fetchData(sp, weakQueue, on_finished);
54  wait_until_done->P();
55  });
56 
58 }

Referenced by 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)
38  {
39  Scroom::Utils::Point<double> const aspectRatio = bmd.aspectRatio ? *bmd.aspectRatio : Scroom::Utils::Point<double>{1, 1};
40  std::string aspect_ratio_text = fmt::format("{:.2f} : {:.2f}", aspectRatio.x, aspectRatio.y);
41 
42  return {
43  {"Color representation", bmd.type},
44  {"Samples per pixel", std::to_string(bmd.samplesPerPixel)},
45  {"Bits per sample", std::to_string(bmd.bitsPerSample)},
46  {"Aspect ratio", aspect_ratio_text},
47  {"Width", std::to_string(bmd.rect.getWidth())},
48  {"Height", std::to_string(bmd.rect.getHeight())},
49  };
50  }
Here is the call graph for this function:

◆ to_stream()

std::ostream & Scroom::TiledBitmap::to_stream ( std::ostream &  os,
const BitmapMetaData bmd 
)
23  {
24  os << "Type=\"" << bmd.type << "\", rect=" << bmd.rect << ", spp=" << bmd.samplesPerPixel << ", bps=" << bmd.bitsPerSample
25  << ", colormapped=" << to_string(static_cast<bool>(bmd.colormapHelper));
26 
27  return os;
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)
31  {
32  std::stringstream ss;
33  to_stream(ss, bmd);
34  return ss.str();
35  }

Referenced by Ruler::drawTicks(), Scroom::Tiff::Source::reset(), 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)
425  {
426  return OpenTiledBitmapAsPresentation::create(std::move(openTiledBitmapInterface));
427  }

Referenced by PluginManager::registerOpenTiledBitmapInterface().

Here is the call graph for this function:
Here is the caller 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"

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

Operations24bpp::create
static Ptr create()
Definition: layeroperations.cc:498
MonochromeColormapHelper::create
static Ptr create(int numberOfColors)
Definition: colormap-helpers.cc:72
OperationsCMYK16::create
static Ptr create()
Definition: cmyklayeroperations.cc:123
Operations8bpp::create
static Ptr create(ColormapProvider::Ptr colormapProvider)
Definition: layeroperations.cc:378
Scroom::TiledBitmap::LayerSpecResult
std::tuple< LayerSpec, ColormapHelperBase::Ptr > LayerSpecResult
Definition: opentiledbitmapinterface.hh:75
ThreadPool::Queue::createAsync
static Ptr createAsync()
Definition: threadpoolimpl.cc:379
Scroom::TiledBitmap::Colormapped
const std::string Colormapped
Definition: layerspecforbitmap.cc:56
Operations1bpp::create
static Ptr create(ColormapProvider::Ptr colormapProvider)
Definition: layeroperations.cc:262
Sequentially
ThreadPool::Ptr Sequentially()
Definition: threadpoolimpl.cc:459
Scroom::Utils::Detail::abort
void abort() __attribute__((noreturn))
Definition: assertions.cc:126
LayerSpec
std::vector< LayerOperations::Ptr > LayerSpec
Definition: tiledbitmapinterface.hh:190
Scroom::TiledBitmap::anonymous_namespace{layerspecforbitmap.cc}::to_string
const char * to_string(bool b)
Definition: layerspecforbitmap.cc:19
require
#define require(expr)
Definition: assertions.hh:28
Scroom::Utils::Point::x
value_type x
Definition: point.hh:111
Scroom::GtkHelpers::sync_on_ui_thread
void sync_on_ui_thread(T f)
Definition: gtk-helpers.hh:59
OperationsCMYK4::create
static Ptr create()
Definition: cmyklayeroperations.cc:306
OperationsCMYK32::create
static Ptr create()
Definition: cmyklayeroperations.cc:30
Scroom::Utils::on_destruction
boost::shared_ptr< void > on_destruction(F f)
Definition: utilities.hh:75
ColormapHelperBase::Ptr
boost::shared_ptr< ColormapHelperBase > Ptr
Definition: colormappable.hh:160
Operations::create
static Ptr create(ColormapProvider::Ptr colormapProvider, int bpp)
Definition: layeroperations.cc:574
anonymous_namespace{progressbarmanager.cc}::instance
ProgressBarPulser::Ptr instance()
Definition: progressbarmanager.cc:43
Scroom::TiledBitmap::CMYK
const std::string CMYK
Definition: layerspecforbitmap.cc:54
OperationsColormapped::create
static Ptr create(ColormapProvider::Ptr colormapProvider, int bpp)
Definition: layeroperations.cc:723
Scroom::TiledBitmap::to_stream
std::ostream & to_stream(std::ostream &os, const BitmapMetaData &bmd)
Definition: layerspecforbitmap.cc:22
create
void create(NewPresentationInterface *interface)
Definition: loader.cc:175
Scroom::Utils::Point::y
value_type y
Definition: point.hh:112
OperationsCMYK8::create
static Ptr create()
Definition: cmyklayeroperations.cc:216
Scroom::TiledBitmap::Greyscale
const std::string Greyscale
Definition: layerspecforbitmap.cc:55
Scroom::TiledBitmap::RGB
const std::string RGB
Definition: layerspecforbitmap.cc:53
Scroom::Utils::Point< double >