AnimaEngine  1.0.0
Nintendo DS Pokemon Black, White, Black 2, and White 2 sprite extraction and preview toolchain
ncgr.h
Go to the documentation of this file.
1 
6 #ifndef NCGR_H
7 #define NCGR_H
8 
9 #include "common.h"
10 #include "nclr.h"
11 
15 typedef struct NcgrImage {
16  const u8 *tile_data;
17  size_t tile_data_size;
19  int bpp;
20  int tile_count;
26 
34 int Ncgr_Parse(
35  const u8 *data,
36  size_t size,
37  NcgrImage *out_image
38 );
39 
44 void Ncgr_PrintInfo(const NcgrImage *image);
45 
50 void Ncgr_Free(NcgrImage *image);
51 
61  const NcgrImage *image,
62  int tile_index,
63  int x,
64  int y
65 );
66 
84  const NcgrImage *image,
85  const NclrPalette *palette,
86  RgbaColor *canvas,
87  int canvas_width,
88  int canvas_height,
89  int dst_x,
90  int dst_y,
91  int tile_index,
92  int obj_width,
93  int obj_height,
94  int palette_index,
95  int flip_h,
96  int flip_v
97 );
98 
117  const NcgrImage *image,
118  const NclrPalette *palette,
119  RgbaColor *canvas,
120  int canvas_width,
121  int canvas_height,
122  int dst_x,
123  int dst_y,
124  int tile_index,
125  int obj_width,
126  int obj_height,
127  int palette_index,
128  int flip_h,
129  int flip_v,
130  int tile_stride
131 );
132 
144  const NcgrImage *image,
145  const NclrPalette *palette,
146  int tiles_per_row,
147  RgbaColor **out_pixels,
148  int *out_width,
149  int *out_height
150 );
151 
152 #endif
153 
Common types, macros, and standard library includes used throughout AnimaEngine.
unsigned char u8
Definition: common.h:14
int Ncgr_GetPixelIndex(const NcgrImage *image, int tile_index, int x, int y)
Retrieves the color index offset for a pixel coordinate inside a specific 8x8 tile.
Definition: ncgr.c:167
struct NcgrImage NcgrImage
Container representing parsed NCGR image tile graphics.
int Ncgr_Parse(const u8 *data, size_t size, NcgrImage *out_image)
Parses character graphics tiles from raw binary stream.
Definition: ncgr.c:5
void Ncgr_Free(NcgrImage *image)
Deallocates local buffers inside NcgrImage structure.
Definition: ncgr.c:129
int Ncgr_RenderTilesToImage(const NcgrImage *image, const NclrPalette *palette, int tiles_per_row, RgbaColor **out_pixels, int *out_width, int *out_height)
Renders sequential list of tiles directly to a grid sheet RGBA image.
Definition: ncgr.c:328
void Ncgr_BlitObjToCanvas(const NcgrImage *image, const NclrPalette *palette, RgbaColor *canvas, int canvas_width, int canvas_height, int dst_x, int dst_y, int tile_index, int obj_width, int obj_height, int palette_index, int flip_h, int flip_v)
Blits a sub-sprite object onto an RGBA canvas.
Definition: ncgr.c:201
void Ncgr_BlitObjToCanvasWithTileStride(const NcgrImage *image, const NclrPalette *palette, RgbaColor *canvas, int canvas_width, int canvas_height, int dst_x, int dst_y, int tile_index, int obj_width, int obj_height, int palette_index, int flip_h, int flip_v, int tile_stride)
Blits a sub-sprite object onto canvas using specific width tile character stride constraints.
Definition: ncgr.c:235
void Ncgr_PrintInfo(const NcgrImage *image)
Debug prints character graphics metadata to stdout.
Definition: ncgr.c:137
Nintendo Color Resource (.NCLR) palette parser.
Container representing parsed NCGR image tile graphics.
Definition: ncgr.h:15
int bpp
Definition: ncgr.h:19
int width_tiles
Definition: ncgr.h:21
int tile_count
Definition: ncgr.h:20
const u8 * tile_data
Definition: ncgr.h:16
size_t tile_data_size
Definition: ncgr.h:17
int height_tiles
Definition: ncgr.h:22
u8 * allocated_data
Definition: ncgr.h:24
Container representing parsed NCLR color palette data.
Definition: nclr.h:17
32-bit RGBA color representation struct.
Definition: ppm.h:14