Scroom 0.14-49-gb7ae7a6d
Loading...
Searching...
No Matches
Operations24bpp Class Reference

#include <layeroperations.hh>

Inheritance diagram for Operations24bpp:
Inheritance graph
Collaboration diagram for Operations24bpp:
Collaboration graph

Public Member Functions

 Operations24bpp ()
 
int getBpp () override
 
Scroom::Utils::Stuff cache (const ConstTile::Ptr &tile) override
 
void reduce (Tile::Ptr target, ConstTile::Ptr source, int x, int y) override
 
- Public Member Functions inherited from PipetteCommonOperationsRGB
 PipetteCommonOperationsRGB (int bps_)
 
PipetteLayerOperations::PipetteColor sumPixelValues (Scroom::Utils::Rectangle< int > area, const ConstTile::Ptr &tile) override
 
- Public Member Functions inherited from Scroom::Utils::Base
 Base ()=default
 
 Base (const Base &)=delete
 
 Base (Base &&)=delete
 
Baseoperator= (const Base &)=delete
 
Baseoperator= (Base &&)=delete
 
virtual ~Base ()=default
 
template<typename R >
std::shared_ptr< R > shared_from_this ()
 
template<typename R >
std::shared_ptr< R const > shared_from_this () const
 
- Public Member Functions inherited from CommonOperations
void initializeCairo (cairo_t *cr) override
 
void drawState (cairo_t *cr, TileState s, Scroom::Utils::Rectangle< double > viewArea) override
 
Scroom::Utils::Stuff cacheZoom (const ConstTile::Ptr &tile, int zoom, Scroom::Utils::Stuff &cache) override
 
void draw (cairo_t *cr, const ConstTile::Ptr &tile, Scroom::Utils::Rectangle< double > tileArea, Scroom::Utils::Rectangle< double > viewArea, int zoom, Scroom::Utils::Stuff cache) override
 

Static Public Member Functions

static Ptr create ()
 
- Static Public Member Functions inherited from CommonOperations
static void drawPixelValue (cairo_t *cr, int x, int y, int size, int value)
 
static void drawPixelValue (cairo_t *cr, int x, int y, int size, int value, Color const &bgColor)
 

Additional Inherited Members

- Public Types inherited from PipetteCommonOperationsRGB
using Ptr = std::shared_ptr< PipetteCommonOperationsRGB >
 
- Public Types inherited from PipetteLayerOperations
using Ptr = std::shared_ptr< PipetteLayerOperations >
 
using PipetteColor = std::vector< std::pair< std::string, double > >
 
- Public Types inherited from LayerOperations
using Ptr = std::shared_ptr< LayerOperations >
 
- Protected Attributes inherited from PipetteCommonOperationsRGB
int bps
 

Constructor & Destructor Documentation

◆ Operations24bpp()

Operations24bpp::Operations24bpp ( )
507{
508}
Definition layeroperations.hh:55

Referenced by create().

Here is the caller graph for this function:

Member Function Documentation

◆ cache()

Scroom::Utils::Stuff Operations24bpp::cache ( const ConstTile::Ptr )
overridevirtual

Cache data for use during later cacheZoom() calls.

This function is called for a given tile, and then the results are passed to the cacheZoom() function. Because draw() is called relatively frequently (i.e. when scrolling), it is recommended to do cpu-intensive work in the cache() and cacheZoom() functions, and then re-use the data to make the draw() faster.

The default implementation returns an empty reference, meaning nothing is cached. As a result, the draw() function will receive an empty reference.

Parameters
tilethe Tile for which caching is requested

Reimplemented from LayerOperations.

513{
514 const int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, tile->width);
515 std::shared_ptr<unsigned char> const data = shared_malloc(stride * tile->height);
516 unsigned char* row = data.get();
517 for(int j = 0; j < tile->height; j++, row += stride)
518 {
519 const byte* cur = tile->data.get() + 3 * j * tile->width;
520
521 auto* pixel = reinterpret_cast<uint32_t*>(row);
522 for(int i = 0; i < tile->width; i++)
523 {
524 // A R G B
525 *pixel = 0xFF000000 | cur[0] << 16 | cur[1] << 8 | cur[2];
526
527 pixel++;
528 cur += 3;
529 }
530 }
531
532 return BitmapSurface::create(tile->width, tile->height, CAIRO_FORMAT_ARGB32, stride, data);
533}
uint8_t data
Definition blob-tests.cc:36
static Ptr create(int width, int height, cairo_format_t format)
Definition bitmap-helpers.cc:13
std::shared_ptr< unsigned char > shared_malloc(size_t size)
Definition layeroperations.cc:28
Here is the call graph for this function:

◆ create()

PipetteCommonOperationsRGB::Ptr Operations24bpp::create ( )
static
Operations24bpp()
Definition layeroperations.cc:505
std::shared_ptr< PipetteCommonOperationsRGB > Ptr
Definition layeroperations.hh:60

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

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

◆ getBpp()

int Operations24bpp::getBpp ( )
overridevirtual

Return the number of bits per pixel that the layer will use.

This number will be used to compute the amount of memory required to store one tile

Implements LayerOperations.

510{ return 24; }

◆ reduce()

void Operations24bpp::reduce ( Tile::Ptr  target,
ConstTile::Ptr  source,
int  x,
int  y 
)
overridevirtual

Reduce the source tile by a factor of 8

The target tile will contain data for 8*8 source tiles. Offsets x and y indicate which of those 64 source tiles is currently being processed

Parameters
targetTile that will contain the reduced bitmap
sourceTile that is to be reduced
xx-offset (0..7) of the source tile in the target tile
yy-offset (0..7) of the source tile in the target tile
Note
The target tile belongs to a different layer, and hence possibly has a different bpp than the current one, depending on the LayerSpec given to createTiledBitmap()

Implements LayerOperations.

536{
537 // Reducing by a factor 8. Source tile is 24bpp. Target tile is 24bpp
538 const int sourceStride = 3 * source->width; // stride in bytes
539 const byte* sourceBase = source->data.get();
540
541 const int targetStride = 3 * target->width; // stride in bytes
542 byte* targetBase = target->data.get() + target->height * y * targetStride / 8 + targetStride * x / 8;
543
544 for(int j = 0; j < source->height / 8; j++, targetBase += targetStride, sourceBase += sourceStride * 8)
545 {
546 // Iterate vertically over target
547 const byte* sourcePtr = sourceBase;
548 byte* targetPtr = targetBase;
549
550 for(int i = 0; i < source->width / 8; i++, sourcePtr += 8 * 3, targetPtr += 3)
551 {
552 // Iterate horizontally over target
553
554 // Goal is to compute a average RGB value from a 8*8 RGB image.
555 const byte* base = sourcePtr;
556 int sum_r = 0;
557 int sum_g = 0;
558 int sum_b = 0;
559 for(int k = 0; k < 8; k++, base += sourceStride)
560 {
561 const byte* current = base;
562 for(int l = 0; l < 8; l++, current += 3)
563 {
564 sum_r += current[0];
565 sum_g += current[1];
566 sum_b += current[2];
567 }
568 }
569 targetPtr[0] = sum_r / 64;
570 targetPtr[1] = sum_g / 64;
571 targetPtr[2] = sum_b / 64;
572 }
573 }
574}
PageList const l
Definition compression-tests.cc:33
static unsigned int current
Definition measure-framerate-callbacks.cc:15

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