92 lines
2.6 KiB
C
92 lines
2.6 KiB
C
/* 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.
|
|
*
|
|
* Returns a block of memory suitable for use with REFRESH_SetTextureData2D.
|
|
* Be sure to free the memory with REFRESH_Image_Free after use!
|
|
*/
|
|
REFRESHAPI uint8_t* REFRESH_Image_Load(
|
|
char const *filename,
|
|
int32_t *w,
|
|
int32_t *h,
|
|
int32_t *numChannels
|
|
);
|
|
|
|
/* Frees memory returned by REFRESH_Image_Load. (Do NOT free the memory yourself!)
|
|
*
|
|
* mem: A pointer previously returned by REFRESH_Image_Load.
|
|
*/
|
|
REFRESHAPI void REFRESH_Image_Free(uint8_t *mem);
|
|
|
|
/* Image Write API */
|
|
|
|
/* Encodes RGBA8 image data into PNG data.
|
|
*
|
|
* filename: The filename that the image will be written to.
|
|
* w: The width of the PNG data.
|
|
* h: The height of the PNG data.
|
|
* data: The raw RGBA8 image data.
|
|
*/
|
|
REFRESHAPI void REFRESH_Image_SavePNG(
|
|
char const *filename,
|
|
int32_t w,
|
|
int32_t h,
|
|
uint8_t *data
|
|
);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif /* __cplusplus */
|
|
|
|
#endif /* REFRESH_IMAGE_H */
|
|
|
|
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */
|