Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
image: add from TR1X
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Aug 23, 2024
1 parent 037ef73 commit b89ed9f
Show file tree
Hide file tree
Showing 3 changed files with 585 additions and 0 deletions.
35 changes: 35 additions & 0 deletions include/libtrx/engine/image.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

typedef struct {
uint8_t r;
uint8_t g;
uint8_t b;
} IMAGE_PIXEL;

typedef struct {
int32_t width;
int32_t height;
IMAGE_PIXEL *data;
} IMAGE;

IMAGE *Image_Create(int width, int height);
IMAGE *Image_CreateFromFile(const char *path);
void Image_Free(IMAGE *image);

bool Image_SaveToFile(const IMAGE *image, const char *path);

IMAGE *Image_ScaleFit(
const IMAGE *source_image, size_t target_width, size_t target_height);

IMAGE *Image_ScaleCover(
const IMAGE *source_image, size_t target_width, size_t target_height);

IMAGE *Image_ScaleStretch(
const IMAGE *source_image, size_t target_width, size_t target_height);

IMAGE *Image_ScaleSmart(
const IMAGE *source_image, size_t target_width, size_t target_height);
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ sources = [
'src/engine/audio.c',
'src/engine/audio_sample.c',
'src/engine/audio_stream.c',
'src/engine/image.c',
'src/filesystem.c',
'src/json/bson_parse.c',
'src/json/bson_write.c',
Expand Down
Loading

0 comments on commit b89ed9f

Please sign in to comment.