Mercurial > molko
view libmlk-core/mlk/core/image.h @ 641:fcd124e513ea
core: reintroduce VFS
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 01 Oct 2023 09:18:01 +0200 |
parents | d307f93d79af |
children |
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; struct mlk_vfs_file; #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); /** * Open an image from a virtual file system. * * The VFS file can be discarded after loading the image. * * \pre texture != NULL * \pre file != NULL * \param texture the texture to initialize * \param file the VFS file * \return 0 on success or -1 on error */ int mlk_image_openvfs(struct mlk_texture *texture, struct mlk_vfs_file *file); #if defined(__cplusplus) } #endif #endif /* !MLK_CORE_IMAGE_H */