view libmlk-core/mlk/core/image.h @ 545:27303e9402de

core: introduce mlk_alloc_expand
author David Demelier <markand@malikania.fr>
date Sun, 05 Mar 2023 22:14:02 +0100
parents 00e7ad6938ae
children d307f93d79af
line wrap: on
line source

/*
 * image.h -- basic image management
 *
 * Copyright (c) 2020-2023 David Demelier <markand@malikania.fr>
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef MLK_CORE_IMAGE_H
#define MLK_CORE_IMAGE_H

/*
 * \file mlk/core/image.h
 * \brief Basic image management
 */

#include <stddef.h>

struct mlk_texture;

#if defined(__cplusplus)
extern "C" {
#endif

/**
 * Open an image from the given filesystem path.
 *
 * The texture must be destroyed using ::mlk_texture_finish once no longer
 * needed.
 *
 * \pre texture != NULL
 * \param texture the texture to initialize
 * \param path path to the image file (e.g. .png, .jpeg, etc)
 * \return 0 on success or any error code instead
 */
int
mlk_image_open(struct mlk_texture *texture, const char *path);

/**
 * Open an image from a const binary data.
 *
 * The binary data must be kept alive until the texture is no longer used.
 *
 * \pre texture != NULL
 * \param texture the texture to initialize
 * \param data the image content
 * \param datasz the image content length
 * \return 0 on success or any error code instead
 */
int
mlk_image_openmem(struct mlk_texture *texture, const void *data, size_t datasz);

#if defined(__cplusplus)
}
#endif

#endif /* !MLK_CORE_IMAGE_H */