Gin
Loading...
Searching...
No Matches
MipMap Class Referencefinal

An image with its halved levels down to 16 px, each halving a rounded 2x2 box average, so drawing it smaller picks the nearest larger level and stays sharp without aliasing. More...

#include <gin_mipmap.h>

Public Types

using Enhance = MipMapEnhance

Public Member Functions

 MipMap ()=default
 MipMap (const juce::Image &src, const Enhance &enhance={})
void setImage (const juce::Image &src, const Enhance &enhance={})
 Builds the levels from an image; a null image leaves the MipMap empty.
void setImage (const juce::File &f, const Enhance &enhance={})
void setImage (const void *rawData, size_t numBytesOfData, const Enhance &enhance={})
void draw (juce::Graphics &g, juce::Rectangle< float > rc, juce::RectanglePlacement placement=0) const
 Draws the level that fits rc at the context's physical pixel scale.
juce::Image getImageFor (const int width, const int height) const
 The level for a size in pixels: the smallest one at least that big, the largest for an empty size.
juce::Image getImage () const
 The full size source level.
juce::Rectangle< int > getBounds () const
int numMipMaps () const
bool isValid () const
bool isNull () const
int getWidth () const
int getHeight () const
int getNumBytesOfData () const
 The pixel memory of all levels.
const Enhance & getEnhance () const
bool operator== (const MipMap &other) const
 The same levels: equal when built from the same setImage() call or a copy of it.

Detailed Description

An image with its halved levels down to 16 px, each halving a rounded 2x2 box average, so drawing it smaller picks the nearest larger level and stays sharp without aliasing.

draw() picks the level for the physical pixel size (HiDPI included) and draws it with low resampling quality when the level matches the size exactly, high otherwise.

Copies are cheap: the levels are juce::Image objects, which share their pixels.

gin::MipMap cover { juce::ImageFileFormat::loadFrom (file) };
void paint (juce::Graphics& g) override
{
cover.draw (g, getLocalBounds().toFloat(), juce::RectanglePlacement::centred);
}
See also
drawBlend, MipMapEnhance

Member Typedef Documentation

◆ Enhance

Constructor & Destructor Documentation

◆ MipMap() [1/2]

MipMap::MipMap ( )
default

Referenced by operator==().

◆ MipMap() [2/2]

MipMap::MipMap ( const juce::Image & src,
const Enhance & enhance = {} )

Member Function Documentation

◆ setImage() [1/3]

void MipMap::setImage ( const juce::Image & src,
const Enhance & enhance = {} )

Builds the levels from an image; a null image leaves the MipMap empty.

◆ setImage() [2/3]

void MipMap::setImage ( const juce::File & f,
const Enhance & enhance = {} )

◆ setImage() [3/3]

void MipMap::setImage ( const void * rawData,
size_t numBytesOfData,
const Enhance & enhance = {} )

◆ draw()

void MipMap::draw ( juce::Graphics & g,
juce::Rectangle< float > rc,
juce::RectanglePlacement placement = 0 ) const

Draws the level that fits rc at the context's physical pixel scale.

◆ getImageFor()

juce::Image MipMap::getImageFor ( const int width,
const int height ) const

The level for a size in pixels: the smallest one at least that big, the largest for an empty size.

◆ getImage()

juce::Image MipMap::getImage ( ) const

The full size source level.

References isValid().

◆ getBounds()

juce::Rectangle< int > MipMap::getBounds ( ) const

◆ numMipMaps()

int MipMap::numMipMaps ( ) const

Referenced by isValid().

◆ isValid()

bool MipMap::isValid ( ) const

References numMipMaps().

Referenced by getHeight(), getImage(), getWidth(), and isNull().

◆ isNull()

bool MipMap::isNull ( ) const

References isValid().

◆ getWidth()

int MipMap::getWidth ( ) const

References isValid().

◆ getHeight()

int MipMap::getHeight ( ) const

References isValid().

◆ getNumBytesOfData()

int MipMap::getNumBytesOfData ( ) const

The pixel memory of all levels.

◆ getEnhance()

const Enhance & MipMap::getEnhance ( ) const

◆ operator==()

bool MipMap::operator== ( const MipMap & other) const

The same levels: equal when built from the same setImage() call or a copy of it.

References MipMap().


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