NetSurf
Macros | Functions | Variables
convert_image.c File Reference
#include <stdbool.h>
#include <errno.h>
#include <stdio.h>
#include <png.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for convert_image.c:

Go to the source code of this file.

Macros

#define png_set_expand_gray_1_2_4_to_8(png)   png_set_gray_1_2_4_to_8(png)
 
#define WIDTH   (is_cursor?raw_width-1:raw_width)
 
#define HEIGHT   (is_cursor?raw_height-1:raw_height)
 
#define HOT_X   (is_cursor?raw_hot_x-1:0)
 
#define HOT_Y   (is_cursor?raw_hot_y-1:0)
 
#define REAL(v)   (is_cursor?v+1:v)
 
#define PPIX_AT(x, y)   ((bitmap_data + (rowstride * y)) + (x * 4))
 
#define R_OFF   2
 
#define G_OFF   1
 
#define B_OFF   0
 
#define A_OFF   3
 
#define R_AT(x, y)   *(PPIX_AT(x,y) + R_OFF)
 
#define G_AT(x, y)   *(PPIX_AT(x,y) + G_OFF)
 
#define B_AT(x, y)   *(PPIX_AT(x,y) + B_OFF)
 
#define A_AT(x, y)   *(PPIX_AT(x,y) + A_OFF)
 

Functions

static void usage (void)
 
static void detect_hotspot (void)
 
static void info_callback (png_structp png, png_infop info)
 
static void row_callback (png_structp png, png_bytep new_row, png_uint_32 row_num, int pass)
 
static void end_callback (png_structp png, png_infop info)
 
int main (int argc, char **argv)
 Normal entry point from OS. More...
 

Variables

static png_structp png
 
static png_infop info
 
static int interlace
 
static size_t rowbytes
 
static int raw_width
 
static int raw_height
 
static int rowstride
 
static unsigned char * bitmap_data
 
static bool is_cursor = true
 
static int raw_hot_x
 
static int raw_hot_y
 
static unsigned int interlace_start [8] = {0, 16, 0, 8, 0, 4, 0}
 
static unsigned int interlace_step [8] = {28, 28, 12, 12, 4, 4, 0}
 
static unsigned int interlace_row_start [8] = {0, 0, 4, 0, 2, 0, 1}
 
static unsigned int interlace_row_step [8] = {8, 8, 8, 4, 4, 2, 2}
 

Macro Definition Documentation

◆ A_AT

#define A_AT (   x,
 
)    *(PPIX_AT(x,y) + A_OFF)

Definition at line 58 of file convert_image.c.

Referenced by detect_hotspot().

◆ A_OFF

#define A_OFF   3

Definition at line 53 of file convert_image.c.

◆ B_AT

#define B_AT (   x,
 
)    *(PPIX_AT(x,y) + B_OFF)

Definition at line 57 of file convert_image.c.

Referenced by detect_hotspot().

◆ B_OFF

#define B_OFF   0

Definition at line 52 of file convert_image.c.

◆ G_AT

#define G_AT (   x,
 
)    *(PPIX_AT(x,y) + G_OFF)

Definition at line 56 of file convert_image.c.

Referenced by detect_hotspot().

◆ G_OFF

#define G_OFF   1

Definition at line 51 of file convert_image.c.

◆ HEIGHT

#define HEIGHT   (is_cursor?raw_height-1:raw_height)

Definition at line 41 of file convert_image.c.

Referenced by main().

◆ HOT_X

#define HOT_X   (is_cursor?raw_hot_x-1:0)

Definition at line 43 of file convert_image.c.

Referenced by main().

◆ HOT_Y

#define HOT_Y   (is_cursor?raw_hot_y-1:0)

Definition at line 44 of file convert_image.c.

Referenced by main().

◆ png_set_expand_gray_1_2_4_to_8

#define png_set_expand_gray_1_2_4_to_8 (   png)    png_set_gray_1_2_4_to_8(png)

Definition at line 27 of file convert_image.c.

Referenced by info_callback().

◆ PPIX_AT

#define PPIX_AT (   x,
 
)    ((bitmap_data + (rowstride * y)) + (x * 4))

Definition at line 48 of file convert_image.c.

◆ R_AT

#define R_AT (   x,
 
)    *(PPIX_AT(x,y) + R_OFF)

Definition at line 55 of file convert_image.c.

Referenced by detect_hotspot().

◆ R_OFF

#define R_OFF   2

Definition at line 50 of file convert_image.c.

◆ REAL

#define REAL (   v)    (is_cursor?v+1:v)

Definition at line 46 of file convert_image.c.

◆ WIDTH

#define WIDTH   (is_cursor?raw_width-1:raw_width)

Definition at line 40 of file convert_image.c.

Referenced by main().

Function Documentation

◆ detect_hotspot()

static void detect_hotspot ( void  )
static

Definition at line 69 of file convert_image.c.

References A_AT, B_AT, G_AT, is_cursor, R_AT, raw_height, raw_hot_x, raw_hot_y, and raw_width.

Referenced by main().

Here is the caller graph for this function:

◆ end_callback()

static void end_callback ( png_structp  png,
png_infop  info 
)
static

Definition at line 205 of file convert_image.c.

Referenced by main().

Here is the caller graph for this function:

◆ info_callback()

static void info_callback ( png_structp  png,
png_infop  info 
)
static

Definition at line 119 of file convert_image.c.

References bitmap_data, height, interlace, png_set_expand_gray_1_2_4_to_8, raw_height, raw_width, rowbytes, rowstride, and width.

Referenced by main().

Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Normal entry point from OS.

Normal entry point from OS.

/param argc The number of arguments in the string vector. /param argv The argument string vector. /return The return code to the OS

Normal entry point from OS.

Todo:
logging file descriptor update belongs in a nslog_init callback
Todo:
decide if message load faliure should be fatal

Definition at line 211 of file convert_image.c.

References bitmap_data, buffer, detect_hotspot(), end_callback(), HEIGHT, HOT_X, HOT_Y, info, info_callback(), is_cursor, png, row_callback(), rowstride, usage(), and WIDTH.

Here is the call graph for this function:

◆ row_callback()

static void row_callback ( png_structp  png,
png_bytep  new_row,
png_uint_32  row_num,
int  pass 
)
static

Definition at line 174 of file convert_image.c.

References bitmap_data, interlace, interlace_row_start, interlace_row_step, interlace_start, interlace_step, rowbytes, and rowstride.

Referenced by main().

Here is the caller graph for this function:

◆ usage()

static void usage ( void  )
static

Definition at line 62 of file convert_image.c.

Referenced by main().

Here is the caller graph for this function:

Variable Documentation

◆ bitmap_data

unsigned char* bitmap_data
static

Definition at line 36 of file convert_image.c.

Referenced by info_callback(), main(), and row_callback().

◆ info

png_infop info
static

◆ interlace

int interlace
static

Definition at line 32 of file convert_image.c.

Referenced by info_callback(), and row_callback().

◆ interlace_row_start

unsigned int interlace_row_start[8] = {0, 0, 4, 0, 2, 0, 1}
static

Definition at line 170 of file convert_image.c.

Referenced by row_callback().

◆ interlace_row_step

unsigned int interlace_row_step[8] = {8, 8, 8, 4, 4, 2, 2}
static

Definition at line 171 of file convert_image.c.

Referenced by row_callback().

◆ interlace_start

unsigned int interlace_start[8] = {0, 16, 0, 8, 0, 4, 0}
static

Definition at line 168 of file convert_image.c.

Referenced by row_callback().

◆ interlace_step

unsigned int interlace_step[8] = {28, 28, 12, 12, 4, 4, 0}
static

Definition at line 169 of file convert_image.c.

Referenced by row_callback().

◆ is_cursor

bool is_cursor = true
static

Definition at line 37 of file convert_image.c.

Referenced by detect_hotspot(), and main().

◆ png

png_structp png
static

Definition at line 30 of file convert_image.c.

Referenced by main().

◆ raw_height

int raw_height
static

Definition at line 34 of file convert_image.c.

Referenced by detect_hotspot(), and info_callback().

◆ raw_hot_x

int raw_hot_x
static

Definition at line 38 of file convert_image.c.

Referenced by detect_hotspot().

◆ raw_hot_y

int raw_hot_y
static

Definition at line 38 of file convert_image.c.

Referenced by detect_hotspot().

◆ raw_width

int raw_width
static

Definition at line 34 of file convert_image.c.

Referenced by detect_hotspot(), and info_callback().

◆ rowbytes

size_t rowbytes
static

Definition at line 33 of file convert_image.c.

Referenced by info_callback(), and row_callback().

◆ rowstride

int rowstride
static