The basic utilities class.
More...
#include <KarmaUtilities.h>
|
static std::string | ReadFileToSpitString (const std::string &filePath) |
| Generates a sting of text contained within a file.
|
|
static std::string | GetFilePath (const std::string &str) |
| Extracts the file path from file source string (filepath + filename.extention)
|
|
static unsigned char * | GetImagePixelData (char const *fileName, int *width, int *height, int *channels, int req_comp) |
| Gathers image pixel data, arranged left-to-right, top-to-bottom, for the supplied image file.
|
|
The basic utilities class.
◆ GetFilePath()
std::string Karma::KarmaUtilities::GetFilePath |
( |
const std::string & | str | ) |
|
|
static |
Extracts the file path from file source string (filepath + filename.extention)
- Parameters
-
str | filepath + filename.extention string |
- Since
- Karma 1.0.0
◆ GetImagePixelData()
unsigned char * Karma::KarmaUtilities::GetImagePixelData |
( |
char const * | fileName, |
|
|
int * | width, |
|
|
int * | height, |
|
|
int * | channels, |
|
|
int | req_comp ) |
|
static |
Gathers image pixel data, arranged left-to-right, top-to-bottom, for the supplied image file.
Few things to note:
- Limitations:
- no 12-bit-per-channel JPEG
- no JPEGs with arithmetic coding
- GIF always returns *comp (or *channels) = 4
- The return value is an 'unsigned char *' which points to the pixel data, or NULL on an allocation failure or if the image is corrupt or invalid. The pixel data consists of *height scanlines of *width pixels, with each pixel consisting of N interleaved 8-bit components; the first pixel pointed to is top-left-most in the image. There is no padding between image scanlines or between pixels, regardless of format. The number of components N is 'desired_channels' if desired_channels is non-zero, or channels otherwise. If desired_channels is non-zero, channels has the number of components that would have been output otherwise. E.g. if you set desired_channels to 4, you will always get RGBA output, but you can check *channels to see if it's trivially opaque because e.g. there were only 3 channels in the source image.
- Parameters
-
fileName | The relative path to the file location |
width | outputs image width in pixels |
height | outputs image height in pixels |
channels | outputs number of image components in image file |
req_comp | (also desired_channels), if non-zero, are number of image components requested in result (rgba?) |
- Since
- Karma 1.0.0
◆ ReadFileToSpitString()
std::string Karma::KarmaUtilities::ReadFileToSpitString |
( |
const std::string & | filePath | ) |
|
|
static |
Generates a sting of text contained within a file.
- Parameters
-
filePath | The relative path of the location of the file to be read |
- See also
- Input::SetGamepadMapping()
- Since
- Karma 1.0.0
The documentation for this class was generated from the following files: