Refresh/include/Refresh_Image.h

94 lines
2.7 KiB
C
Raw Permalink Normal View History

2020-12-28 06:45:12 +00:00
/* Refresh - XNA-inspired 3D Graphics Library with modern capabilities
*
* Copyright (c) 2020 Ethan Lee and Evan Hemsley
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from
* the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software in a
* product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
* Ethan "flibitijibibo" Lee <flibitijibibo@flibitijibibo.com>
* Evan "cosmonaut" Hemsley <evan@moonside.games>
*
* This source file is heavily borrowed from FNA3D_Image.h and was originally
* written by Ethan Lee.
*/
#ifndef REFRESH_IMAGE_H
#define REFRESH_IMAGE_H
#ifdef _WIN32
#define REFRESHAPI __declspec(dllexport)
#define REFRESHCALL __cdecl
#else
#define REFRESHAPI
#define REFRESHCALL
#endif
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Decodes PNG data into raw RGBA8 texture data.
*
* w: Filled with the width of the image.
* h: Filled with the height of the image.
* numChannels: Filled with the number of channels in the image.
*
2021-01-05 23:00:51 +00:00
* Returns a block of memory suitable for use with Refresh_SetTextureData2D.
* Be sure to free the memory with Refresh_Image_Free after use!
2020-12-28 06:45:12 +00:00
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI uint8_t* Refresh_Image_Load(
2022-02-25 21:42:11 +00:00
char const *filename,
2020-12-28 06:45:12 +00:00
int32_t *w,
int32_t *h,
2022-02-25 21:42:11 +00:00
int32_t *numChannels
2020-12-28 06:45:12 +00:00
);
2021-01-05 23:00:51 +00:00
/* Frees memory returned by Refresh_Image_Load. (Do NOT free the memory yourself!)
2020-12-28 06:45:12 +00:00
*
2021-01-05 23:00:51 +00:00
* mem: A pointer previously returned by Refresh_Image_Load.
2020-12-28 06:45:12 +00:00
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_Image_Free(uint8_t *mem);
2020-12-28 06:45:12 +00:00
/* Image Write API */
/* Encodes 32-bit color data into PNG data.
2020-12-28 06:45:12 +00:00
*
* filename: The filename that the image will be written to.
* w: The width of the PNG data.
* h: The height of the PNG data.
* bgra: Whether the data is in BGRA8 format. Otherwise will assume RBGA8.
* data: The raw color data.
2020-12-28 06:45:12 +00:00
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_Image_SavePNG(
2022-02-25 21:42:11 +00:00
char const *filename,
int32_t w,
int32_t h,
uint8_t bgra,
2020-12-28 06:45:12 +00:00
uint8_t *data
);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* REFRESH_IMAGE_H */
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */