mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-12 15:13:34 +00:00
working on xpm support
This commit is contained in:
46
src/utils/xpm_reader.cpp
git.filemode.normal_file
46
src/utils/xpm_reader.cpp
git.filemode.normal_file
@@ -0,0 +1,46 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* xpm_reader.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/04/05 13:37:21 by maldavid #+# #+# */
|
||||
/* Updated: 2023/04/05 13:53:30 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <utils/xpm_reader.h>
|
||||
#include <core/errors.h>
|
||||
#include <cstdio>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
std::vector<uint8_t> parseXpmFile(std::filesystem::path file, int* w, int* h)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<uint8_t> parseXpmData(char** data, int* w, int* h)
|
||||
{
|
||||
if(data == nullptr)
|
||||
{
|
||||
core::error::report(e_kind::error, "Xpm reader : null data");
|
||||
return {};
|
||||
}
|
||||
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t ncolors;
|
||||
uint32_t cpp; // chars per pixels
|
||||
|
||||
if(std::sscanf(data[0], "%d %d %d %d", &width, &height, &ncolors, &cpp) != 4)
|
||||
{
|
||||
core::error::report(e_kind::error, "Xpm reader : invalid pixmap description");
|
||||
return {};
|
||||
}
|
||||
|
||||
*w = width;
|
||||
*h = height;
|
||||
}
|
||||
}
|
||||
26
src/utils/xpm_reader.h
git.filemode.normal_file
26
src/utils/xpm_reader.h
git.filemode.normal_file
@@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* xpm_reader.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/04/05 13:25:55 by maldavid #+# #+# */
|
||||
/* Updated: 2023/04/05 13:35:48 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef __MLX_XPM_READER__
|
||||
#define __MLX_XPM_READER__
|
||||
|
||||
#include <filesystem>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
std::vector<uint8_t> parseXpmData(char** data, int* w, int* h);
|
||||
std::vector<uint8_t> parseXpmFile(std::filesystem::path file, int* w, int* h);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user