Files
itgmania212121/src/RageSurfaceUtils.h
T

94 lines
3.9 KiB
C++
Raw Normal View History

2011-03-17 01:47:30 -04:00
/* Utility functions for RageSurfaces. */
#ifndef RAGE_SURFACE_UTILS_H
#define RAGE_SURFACE_UTILS_H
2023-04-20 12:34:12 +02:00
#include <cstdint>
2011-03-17 01:47:30 -04:00
struct RageSurfaceColor;
struct RageSurfacePalette;
struct RageSurfaceFormat;
struct RageSurface;
/** @brief Utility functions for the RageSurfaces. */
namespace RageSurfaceUtils
{
2024-10-05 17:51:14 -07:00
uint32_t decodepixel( const uint8_t *p, int bpp );
void encodepixel( uint8_t *p, int bpp, uint32_t pixel );
2011-03-17 01:47:30 -04:00
2024-10-05 17:51:14 -07:00
void GetRawRGBAV( uint32_t pixel, const RageSurfaceFormat &fmt, uint8_t *v );
void GetRawRGBAV( const uint8_t *p, const RageSurfaceFormat &fmt, uint8_t *v );
void GetRGBAV( uint32_t pixel, const RageSurface *src, uint8_t *v );
void GetRGBAV( const uint8_t *p, const RageSurface *src, uint8_t *v );
2011-03-17 01:47:30 -04:00
2024-10-05 17:51:14 -07:00
uint32_t SetRawRGBAV( const RageSurfaceFormat *fmt, const uint8_t *v );
void SetRawRGBAV( uint8_t *p, const RageSurface *src, const uint8_t *v );
uint32_t SetRGBAV( const RageSurfaceFormat *fmt, const uint8_t *v );
void SetRGBAV( uint8_t *p, const RageSurface *src, const uint8_t *v );
2011-03-17 01:47:30 -04:00
/* Get the number of bits representing each color channel in fmt. */
2024-10-05 17:51:14 -07:00
void GetBitsPerChannel( const RageSurfaceFormat *fmt, uint32_t bits[4] );
2011-03-17 01:47:30 -04:00
void CopySurface( const RageSurface *src, RageSurface *dest );
2013-01-01 17:40:29 +01:00
bool ConvertSurface( const RageSurface *src, RageSurface *&dst,
2024-10-05 17:51:14 -07:00
int width, int height, int bpp, uint32_t R, uint32_t G, uint32_t B, uint32_t A );
2011-03-17 01:47:30 -04:00
void ConvertSurface( RageSurface *&image,
2024-10-05 17:51:14 -07:00
int width, int height, int bpp, uint32_t R, uint32_t G, uint32_t B, uint32_t A );
2011-03-17 01:47:30 -04:00
void FixHiddenAlpha( RageSurface *img );
int FindSurfaceTraits( const RageSurface *img );
/* The surface contains no transparent pixels and/or never uses its color
* key, so it doesn't need any alpha bits at all. */
enum { TRAIT_NO_TRANSPARENCY = 0x0001 }; /* 0alpha */
/* The surface contains only transparent values of 0 or 1; no translucency.
* It only needs one bit of alpha. */
enum { TRAIT_BOOL_TRANSPARENCY = 0x0002 }; /* 1alpha */
2023-04-20 12:34:12 +02:00
void BlitTransform( const RageSurface *src, RageSurface *dst,
2011-03-17 01:47:30 -04:00
const float fCoords[8] /* TL, BR, BL, TR */ );
void Blit( const RageSurface *src, RageSurface *dst, int width = -1, int height = -1 );
void CorrectBorderPixels( RageSurface *img, int width, int height );
bool SaveSurface( const RageSurface *img, RString file );
RageSurface *LoadSurface( RString file );
/* Quickly palettize to an gray/alpha texture. */
2022-12-23 12:34:02 -07:00
RageSurface *PalettizeToGrayscale( const RageSurface *src_surf, unsigned int GrayBits, unsigned int AlphaBits );
2011-03-17 01:47:30 -04:00
RageSurface *MakeDummySurface( int height, int width );
void ApplyHotPinkColorKey( RageSurface *&img );
void FlipVertically( RageSurface *img );
};
#endif
/*
* (c) 2001-2004 Glenn Maynard, Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL 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.
*/