Scroom 0.14-48-ga0fee447
Loading...
Searching...
No Matches
tiled-bitmap.cc File Reference
#include "tiled-bitmap.hh"
#include <cmath>
#include <cstdio>
#include <fmt/format.h>
#include <spdlog/spdlog.h>
#include <boost/thread/mutex.hpp>
#include <scroom/cairo-helpers.hh>
#include <scroom/semaphore.hh>
#include "tileviewstate.hh"
Include dependency graph for tiled-bitmap.cc:

Functions

TiledBitmapInterface::Ptr createTiledBitmap (int bitmapWidth, int bitmapHeight, LayerSpec const &ls)
 
Scroom::Utils::Rectangle< int > TileAreaForIndex (Scroom::Utils::Point< int > tileIndex)
 

Function Documentation

◆ createTiledBitmap()

TiledBitmapInterface::Ptr createTiledBitmap ( int  bitmapWidth,
int  bitmapHeight,
LayerSpec const &  ls 
)

Create a tiled bitmap.

In a TiledBitmap, your bitmap is distributed over tiles, that each contain a square portion of your bitmap. These tiles will be swapped in or out as required, depending on the amount of available memory. This way, you can "load" bitmaps that are larger than your amount of memory would normally allow.

Of course, when zooming out, you'd still need all the data in your bitmap, in order to show the scaled down version. To avoid this, createTiledBitmap() creates pre-scaled versions of your bitmap, that are reduced by a factor 8. Such a pre-scaled version is called a Layer. If your bitmap gets very large, several pre-scaled versions are created, reduced by a factor 8, 64, 512, 4096, etc.

So, to summarize, createTiledBitmap() creates several layers of your bitmap, at zoom levels 1:1, 1:8, 1:64, etc. Each layer is then divided into tiles, such that only the relevant part can be loaded into memory.

Of course createTiledBitmap() doesn't know anything about how you choose to represent your bitmap data, so you'll have to specify (by implementing LayerOperations) how to draw portions of your bitmap at given zoom levels, and how to pre-scale your bitmap.

Note
When calling createTiledBitmap(), all the internal data structures will be set up. You still have to fill your bitmap with data, for example by calling TiledBitmapInterface::setSource()
Parameters
bitmapWidththe width of the bitmap
bitmapHeightthe height of the bitmap
lsLayerOperations objects, specifying how to draw (portions of) your bitmap at given zoom levels
Returns
A pointer to a newly created TiledBitmapInterface. You can use this pointer to manipulate your bitmap.
28{
29 return TiledBitmap::create(bitmapWidth, bitmapHeight, ls);
30}
static Ptr create(int bitmapWidth, int bitmapHeight, LayerSpec const &ls)
Definition tiled-bitmap.cc:72

Referenced by setupTest1bpp(), setupTest2bpp(), setupTest4bpp(), setupTest8bpp(), and setupTest8bppColormapped().

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

◆ TileAreaForIndex()

Scroom::Utils::Rectangle< int > TileAreaForIndex ( Scroom::Utils::Point< int >  tileIndex)
inline
65{
66 return (Scroom::Utils::Rectangle<int>(0, 0, 1, 1) + tileIndex) * TILESIZE;
67}
Definition rectangle.hh:29
#define TILESIZE
Definition tiledbitmaplayer.hh:27

Referenced by TiledBitmap::redraw().

Here is the caller graph for this function: