kviewshell
GBitmapScaler Class Reference
Fast rescaling code for gray level images. More...
#include <GScaler.h>
Public Member Functions | |
void | scale (const GRect &provided_input, const GBitmap &input, const GRect &desired_output, GBitmap &output) |
virtual | ~GBitmapScaler () |
Static Public Member Functions | |
static GP< GBitmapScaler > | create (const int inw, const int inh, const int outw, const int outh) |
static GP< GBitmapScaler > | create (void) |
Protected Member Functions | |
GBitmapScaler (int inw, int inh, int outw, int outh) | |
GBitmapScaler (void) | |
unsigned char * | get_line (int, const GRect &, const GRect &, const GBitmap &) |
Protected Attributes | |
unsigned char * | conv |
GPBuffer< unsigned char > | gconv |
GPBuffer< unsigned char > | glbuffer |
GPBuffer< unsigned char > | gp1 |
GPBuffer< unsigned char > | gp2 |
int | l1 |
int | l2 |
unsigned char * | lbuffer |
unsigned char * | p1 |
unsigned char * | p2 |
Detailed Description
Fast rescaling code for gray level images.This class augments the base class {GScaler} with a function for rescaling gray level images. Function {GBitmapScaler::scale} computes an arbitrary segment of the output image given the corresponding pixels in the input image.
{ Example} --- The following functions returns an gray level image (sixteen gray levels, size nw# by nh#) containing a rescaled version of the input image in#. {verbatim} GBitmap *rescale_bitmap(const GBitmap &in, int nw, int nh) { int w = in.columns(); // Get input width int h = in.raws(); // Get output width GBitmapScaler scaler(w,h,nw,nh); // Creates bitmap scaler GRect desired(0,0,nw,nh); // Desired output = complete bitmap GRect provided(0,0,w,h); // Provided input = complete bitmap GBitmap *out = new GBitmap; scaler.scale(provided, in, desired, *out); // Rescale out->change_grays(16); // Reduce to 16 gray levels return out; } {verbatim}
Definition at line 185 of file GScaler.h.
Constructor & Destructor Documentation
GBitmapScaler::GBitmapScaler | ( | void | ) | [protected] |
Definition at line 305 of file GScaler.cpp.
GBitmapScaler::GBitmapScaler | ( | int | inw, | |
int | inh, | |||
int | outw, | |||
int | outh | |||
) | [protected] |
Definition at line 311 of file GScaler.cpp.
GBitmapScaler::~GBitmapScaler | ( | ) | [virtual] |
Member Function Documentation
static GP<GBitmapScaler> GBitmapScaler::create | ( | const int | inw, | |
const int | inh, | |||
const int | outw, | |||
const int | outh | |||
) | [inline, static] |
Creates a GBitmapScaler.
The size of the input image is given by inw# and inh#. This function internally calls {GScaler::set_input_size} and {GScaler::set_output_size}. The size of the output image is given by outw# and outh#. .
static GP<GBitmapScaler> GBitmapScaler::create | ( | void | ) | [inline, static] |
Creates an empty GBitmapScaler.
You must call functions {GScaler::set_input_size} and {GScaler::set_output_size} before calling any of the scaling functions.
unsigned char * GBitmapScaler::get_line | ( | int | fy, | |
const GRect & | required_red, | |||
const GRect & | provided_input, | |||
const GBitmap & | input | |||
) | [protected] |
Definition at line 325 of file GScaler.cpp.
void GBitmapScaler::scale | ( | const GRect & | provided_input, | |
const GBitmap & | input, | |||
const GRect & | desired_output, | |||
GBitmap & | output | |||
) |
Computes a segment of the rescaled output image.
The GBitmap object output# is overwritten with the segment of the output image specified by the rectangle desired_output#. The rectangle provided_input# specifies which segment of the input image is provided by the GBitmap object input#. An exception {GException} is thrown if the rectangle provided_input# is smaller then the rectangle required_input# returned by function {GScaler::get_input_rect}. Note that the output image always contain 256 gray levels. You may want to use function {GBitmap::change_grays} to reduce the number of gray levels.
Definition at line 399 of file GScaler.cpp.
Member Data Documentation
unsigned char* GBitmapScaler::conv [protected] |
GPBuffer<unsigned char> GBitmapScaler::gconv [protected] |
GPBuffer<unsigned char> GBitmapScaler::glbuffer [protected] |
GPBuffer<unsigned char> GBitmapScaler::gp1 [protected] |
GPBuffer<unsigned char> GBitmapScaler::gp2 [protected] |
int GBitmapScaler::l1 [protected] |
int GBitmapScaler::l2 [protected] |
unsigned char* GBitmapScaler::lbuffer [protected] |
unsigned char* GBitmapScaler::p1 [protected] |
unsigned char* GBitmapScaler::p2 [protected] |
The documentation for this class was generated from the following files: