Audacity  2.2.0
ImageManipulation.cpp File Reference
#include <wx/image.h>
#include "Audacity.h"
#include "ImageManipulation.h"
#include "AllThemeResources.h"
#include "Theme.h"

Functions

std::unique_ptr< wxImage > ChangeImageColour (wxImage *srcImage, wxColour &dstColour)
 
std::unique_ptr< wxImage > ChangeImageColour (wxImage *srcImage, wxColour &srcColour, wxColour &dstColour)
 
std::unique_ptr< wxImage > OverlayImage (wxImage *background, wxImage *foreground, wxImage *mask, int xoff, int yoff)
 
std::unique_ptr< wxImage > OverlayImage (teBmps eBack, teBmps eForeground, int xoff, int yoff)
 
std::unique_ptr< wxImage > CreateBackground (int width, int height, wxColour colour)
 
std::unique_ptr< wxImage > CreateAquaBackground (int width, int height, int offset)
 
std::unique_ptr< wxImage > CreateSysBackground (int width, int height, int WXUNUSED(offset), wxColour colour)
 
void PasteSubImage (wxImage *background, wxImage *foreground, int xoff, int yoff)
 
wxImage GetSubImageWithAlpha (const wxImage &Src, const wxRect &rect)
 

Detailed Description

Provides Image Manipulation functions.

wxWidgets misses some important functions involving cutting and pasting bitmaps, and (in version 2.6.1) is patchy in support of alpha channel. This collection of functions fills that gap.

Function Documentation

std::unique_ptr<wxImage> ChangeImageColour ( wxImage *  srcImage,
wxColour &  dstColour 
)

This looks at the first pixel in the image, and shifts the entire image by the vector difference between that pixel and the dstColour. For better control, use ChangeImageColour(wxImage, wxColour*, wxColour*) below

References ChangeImageColour().

Referenced by ChangeImageColour(), ToolBar::MakeRecoloredImage(), and ThemeBase::RecolourBitmap().

std::unique_ptr<wxImage> ChangeImageColour ( wxImage *  srcImage,
wxColour &  srcColour,
wxColour &  dstColour 
)

This will explicitly shift the image color from srcColour to dstColour.

std::unique_ptr<wxImage> CreateAquaBackground ( int  width,
int  height,
int  offset 
)

Referenced by CreateSysBackground().

std::unique_ptr<wxImage> CreateBackground ( int  width,
int  height,
wxColour  colour 
)

Referenced by CreateSysBackground().

std::unique_ptr<wxImage> CreateSysBackground ( int  width,
int  height,
int   WXUNUSEDoffset,
wxColour  colour 
)
wxImage GetSubImageWithAlpha ( const wxImage &  Src,
const wxRect &  rect 
)

Gets a rectangle from within another image, INCLUDING the alpha channel

Bug:
in wxWidgets, wxImage::GetSubImage should do this itself.

Referenced by ThemeBase::ReadImageCache().

std::unique_ptr<wxImage> OverlayImage ( wxImage *  background,
wxImage *  foreground,
wxImage *  mask,
int  xoff,
int  yoff 
)

Takes a background image, foreground image, and mask (i.e. the alpha channel for the foreground), and returns an NEW image where the foreground has been overlaid onto the background using alpha-blending, at location (xoff, yoff).

Referenced by ToolBar::MakeAlternateImages(), and ToolBar::MakeButton().

std::unique_ptr<wxImage> OverlayImage ( teBmps  eBack,
teBmps  eForeground,
int  xoff,
int  yoff 
)

Takes a background image, foreground image, and mask (i.e. the alpha channel for the foreground), and returns an NEW image where the foreground has been overlaid onto the background using alpha-blending, at location (xoff, yoff).

References ThemeBase::Colour(), ThemeBase::Image(), and theTheme.

void PasteSubImage ( wxImage *  background,
wxImage *  foreground,
int  xoff,
int  yoff 
)

Pastes one image into another including the alpha channel. Differs from OverlayImage in that: Happens in place to existing background image. Pastes image on top; no blending with existing background is done.

Referenced by ThemeBase::CreateImageCache().