Porytiles
Loading...
Searching...
No Matches
porytiles2::ImageTileizer< T > Class Template Reference

Service for converting images into collections of 8x8 tiles. More...

#include <image_tileizer.hpp>

Public Member Functions

ChainableResult< std::vector< PixelTile< T > > > tileize (const Image< T > &img) const
 Converts an image into a vector of 8x8 tiles.
 

Detailed Description

template<typename T>
class porytiles2::ImageTileizer< T >

Service for converting images into collections of 8x8 tiles.

The ImageTileizer service provides functionality to decompose images into individual 8x8 pixel tiles. This is a fundamental operation in tileset compilation, where large images need to be broken down into the tile-based format used by the Game Boy Advance graphics system.

The service validates that input images have dimensions that are multiples of the tile size (8 pixels) and processes the image in row-major order, creating tiles from left-to-right, top-to-bottom. Each resulting PixelTile<T> contains the exact pixel data from the corresponding 8x8 region of the source image.

Template Parameters
TThe pixel type (e.g., Rgba32, IndexPixel)

Definition at line 29 of file image_tileizer.hpp.

Member Function Documentation

◆ tileize()

template<typename T >
ChainableResult< std::vector< PixelTile< T > > > porytiles2::ImageTileizer< T >::tileize ( const Image< T > &  img) const
inline

Converts an image into a vector of 8x8 tiles.

This method decomposes the input image into individual 8x8 pixel tiles, processing the image in row-major order (left-to-right, top-to-bottom). The resulting tiles contain the exact pixel data from their corresponding regions in the source image.

The method validates that the image dimensions are multiples of 8 pixels, as partial tiles are not supported in the Game Boy Advance graphics system. If the validation fails, an error is returned with details about the invalid dimensions.

For an image of width W and height H pixels:

  • Number of tiles per row: W / 8
  • Number of tile rows: H / 8
  • Total tiles: (W / 8) * (H / 8)
  • Tile ordering: tiles[row * tiles_per_row + col] where row and col are tile coordinates
Parameters
imgThe source image to tileize
Template Parameters
TThe pixel type (e.g., Rgba32, IndexPixel)
Returns
A ChainableResult containing either:
  • Success: A vector of PixelTile<T> objects in row-major order
  • Error: A FormattableError describing why tileization failed (e.g., invalid dimensions)

Definition at line 55 of file image_tileizer.hpp.


The documentation for this class was generated from the following file: