Refresh/include/Refresh_Image.h

109 lines
2.9 KiB
C
Raw 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 */
/* Image Read API */
2020-12-28 06:45:12 +00:00
/* Decodes image data into raw RGBA8 texture data.
*
* w: Filled with the width of the image.
* h: Filled with the height of the image.
* len: Filled with the length of pixel data in bytes.
*
* 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(
uint8_t *bufferPtr,
int32_t bufferLength,
int32_t *w,
int32_t *h,
int32_t *len
);
2024-02-23 08:03:17 +00:00
/* Get image dimensions without fully decoding the image.
*
* w: Filled with the width of the image.
* h: Filled with the height of the image.
* len: Filled with the length of pixel data in bytes.
*/
REFRESHAPI uint8_t Refresh_Image_Info(
uint8_t *bufferPtr,
int32_t bufferLength,
int32_t *w,
int32_t *h,
int32_t *len
);
/* Frees memory returned by Refresh_Image_Load. Do NOT free the memory yourself!
2020-12-28 06:45:12 +00:00
*
* mem: A pointer previously returned by Refresh_Image_LoadPNG.
2020-12-28 06:45:12 +00:00
*/
REFRESHAPI void Refresh_Image_Free(uint8_t *mem);
2020-12-28 06:45:12 +00:00
/* Image Write API */
/* Returns a buffer of PNG encoded from RGBA8 color data.
2020-12-28 06:45:12 +00:00
*
* data: The raw color data.
* w: The width of the color data.
* h: The height of the color data.
* len: Filled with the length of PNG data in bytes.
2020-12-28 06:45:12 +00:00
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_Image_SavePNG(
const char* filename,
uint8_t* data,
int32_t w,
int32_t h
);
2020-12-28 06:45:12 +00:00
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* REFRESH_IMAGE_H */
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */