The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
icon.c File Reference

icons from the icon packs (the format is in tools/icons/build.py). More...

#include "icon.h"
#include <fcntl.h>
#include <image.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

Macros

#define HEADER_SIZE   16
#define ENTRY_SIZE   48
#define COUNT_MAX   65536
#define SIDE_MAX   1024

Functions

icon_set_t * icon_set_open (const char *path)
 open a pack file.
icon_set_t * icon_set_named (const char *name)
 open a set by its name: ICON_DIR "<name>.pack".
void icon_set_close (icon_set_t *set)
bool icon_set_is_mask (const icon_set_t *set)
 true if the set is of masks (lucide), false if of colour images (tela).
bool icon_set_has (const icon_set_t *set, const char *name)
 true if the set has an icon of exactly this name.
icon_t * icon_load (icon_set_t *set, const char *name, int32_t size, int32_t scale)
 load an icon.
void icon_free (icon_t *icon)
void icon_draw_mask (gfx_buffer_t *buf, const icon_t *icon, int32_t x, int32_t y, gfx_color_t color)
 draw an icon in a colour: a mask's coverage, or a colour image's alpha.
void icon_draw (gfx_buffer_t *buf, const icon_t *icon, int32_t x, int32_t y, uint8_t opacity)
 draw an icon as it is, with an opacity (255: opaque).

Detailed Description

icons from the icon packs (the format is in tools/icons/build.py).

the index of a pack is read when it is opened; an image is read from the file and decompressed (zlib, through the image library) when it is loaded.

Macro Definition Documentation

◆ HEADER_SIZE

#define HEADER_SIZE   16

◆ ENTRY_SIZE

#define ENTRY_SIZE   48

◆ COUNT_MAX

#define COUNT_MAX   65536

◆ SIDE_MAX

#define SIDE_MAX   1024

Function Documentation

◆ icon_set_open()

icon_set_t * icon_set_open ( const char * path)

open a pack file.

Returns
the set, or NULL (no file, or not an icon pack).

◆ icon_set_named()

icon_set_t * icon_set_named ( const char * name)

open a set by its name: ICON_DIR "<name>.pack".

◆ icon_set_close()

void icon_set_close ( icon_set_t * set)

◆ icon_set_is_mask()

bool icon_set_is_mask ( const icon_set_t * set)

true if the set is of masks (lucide), false if of colour images (tela).

◆ icon_set_has()

bool icon_set_has ( const icon_set_t * set,
const char * name )

true if the set has an icon of exactly this name.

◆ icon_load()

icon_t * icon_load ( icon_set_t * set,
const char * name,
int32_t size,
int32_t scale )

load an icon.

a name the set does not have falls back as in the freedesktop icon naming spec: the last part after a dash is removed until a name is found (text-x-csrc, text-x, text), then "unknown".

Parameters
sizethe icon size in points (16, 20, 24, 32, 48, 64, or any).
scale1 to 4 (2 for a 2x screen); the icon is size * scale pixels, at most 1024.
Returns
the icon (free it with icon_free), or NULL.

◆ icon_free()

void icon_free ( icon_t * icon)

◆ icon_draw_mask()

void icon_draw_mask ( gfx_buffer_t * buf,
const icon_t * icon,
int32_t x,
int32_t y,
gfx_color_t color )

draw an icon in a colour: a mask's coverage, or a colour image's alpha.

◆ icon_draw()

void icon_draw ( gfx_buffer_t * buf,
const icon_t * icon,
int32_t x,
int32_t y,
uint8_t opacity )

draw an icon as it is, with an opacity (255: opaque).

a mask is drawn in black.