Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://coin3d.github.io
https://www.kongsberg.com/en/kogt/
Data Structures | Macros | Functions
resize.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <simage.h>

Go to the source code of this file.

Data Structures

struct  Image
 
struct  CONTRIB
 
struct  CLIST
 

Macros

#define M_PI   3.14159265358979323846
 
#define filter_support   (1.0f)
 
#define box_support   (0.5f)
 
#define triangle_support   (1.0f)
 
#define bell_support   (1.5f)
 
#define B_spline_support   (2.0f)
 
#define Lanczos3_support   (3.0f)
 
#define Mitchell_support   (2.0)
 
#define B   (1.0f / 3.0f)
 
#define C   (1.0f / 3.0f)
 

Functions

static void get_row (unsigned char *row, Image *image, int y)
 
static void get_column (unsigned char *column, Image *image, int x)
 
static void put_pixel (Image *image, int x, int y, float *data)
 
static float filter (float t)
 
static float box_filter (float t)
 
static float triangle_filter (float t)
 
static float bell_filter (float t)
 
static float B_spline_filter (float t)
 
static float sinc (float x)
 
static float Lanczos3_filter (float t)
 
static float Mitchell_filter (float t)
 
static Imagenew_image (int xsize, int ysize, int bpp, unsigned char *data)
 
static void zoom (Image *dst, Image *src, float(*filterf)(float), float fwidth)
 
static unsigned char * simage_resize_fast (unsigned char *src, int width, int height, int num_comp, int newwidth, int newheight)
 
unsigned char * simage_resize (unsigned char *src, int width, int height, int num_comp, int newwidth, int newheight)
 

Macro Definition Documentation

#define B   (1.0f / 3.0f)

Definition at line 193 of file resize.c.

Referenced by Mitchell_filter().

#define B_spline_support   (2.0f)

Definition at line 155 of file resize.c.

#define bell_support   (1.5f)

Definition at line 141 of file resize.c.

Referenced by simage_resize().

#define box_support   (0.5f)

Definition at line 122 of file resize.c.

#define C   (1.0f / 3.0f)

Definition at line 194 of file resize.c.

Referenced by Mitchell_filter().

#define filter_support   (1.0f)

Definition at line 111 of file resize.c.

#define Lanczos3_support   (3.0f)

Definition at line 181 of file resize.c.

#define M_PI   3.14159265358979323846

Definition at line 43 of file resize.c.

Referenced by sinc().

#define Mitchell_support   (2.0)

Definition at line 191 of file resize.c.

#define triangle_support   (1.0f)

Definition at line 131 of file resize.c.

Function Documentation

static float B_spline_filter ( float  t)
static

Definition at line 158 of file resize.c.

static float bell_filter ( float  t)
static

Definition at line 144 of file resize.c.

Referenced by simage_resize().

static float box_filter ( float  t)
static

Definition at line 125 of file resize.c.

static float filter ( float  t)
static

Definition at line 114 of file resize.c.

static void get_column ( unsigned char *  column,
Image image,
int  x 
)
static

Definition at line 66 of file resize.c.

References Image::bpp, Image::data, Image::span, and Image::ysize.

Referenced by zoom().

static void get_row ( unsigned char *  row,
Image image,
int  y 
)
static

Definition at line 55 of file resize.c.

References Image::bpp, Image::data, Image::span, and Image::xsize.

Referenced by zoom().

static float Lanczos3_filter ( float  t)
static

Definition at line 184 of file resize.c.

References sinc().

static float Mitchell_filter ( float  t)
static

Definition at line 197 of file resize.c.

References B, and C.

static Image* new_image ( int  xsize,
int  ysize,
int  bpp,
unsigned char *  data 
)
static

Definition at line 234 of file resize.c.

References Image::bpp, Image::data, Image::span, Image::xsize, and Image::ysize.

Referenced by simage_resize(), and zoom().

static void put_pixel ( Image image,
int  x,
int  y,
float *  data 
)
static

Definition at line 85 of file resize.c.

References Image::bpp, Image::data, and Image::span.

Referenced by zoom().

unsigned char* simage_resize ( unsigned char *  imagedata,
int  width,
int  height,
int  numcomponents,
int  newwidth,
int  newheight 
)

Since OpenGL textures must have width and height equal to 2^n, this is often needed. A pointer to the new image data is returned. imagedata is not freed. Uses the algorithm "Filtered Image Rescaling" by Dale Schumacher, from GGems III.

Scales the input imagedata and return a new image with the given dimensions returned image buffer must be freed by simage_free_image()

Definition at line 512 of file resize.c.

References bell_filter(), bell_support, Image::data, new_image(), simage_resize_fast(), and zoom().

static unsigned char* simage_resize_fast ( unsigned char *  src,
int  width,
int  height,
int  num_comp,
int  newwidth,
int  newheight 
)
static

Definition at line 466 of file resize.c.

Referenced by simage_resize().

static float sinc ( float  x)
static

Definition at line 174 of file resize.c.

References M_PI.

Referenced by Lanczos3_filter().

static float triangle_filter ( float  t)
static

Definition at line 134 of file resize.c.

static void zoom ( Image dst,
Image src,
float(*)(float)  filterf,
float  fwidth 
)
static