Porytiles
Loading...
Searching...
No Matches
anim_frame_loader.hpp File Reference

Shared helper for loading animation frames from PNG files. More...

Include dependency graph for anim_frame_loader.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  porytiles::FrameLoadResult< PixelType >
 Result of loading an animation frame from a PNG file. More...
 

Namespaces

namespace  porytiles
 

Functions

template<SupportsTransparency PixelType, typename LoaderType >
ChainableResult< FrameLoadResult< PixelType > > porytiles::load_animation_frame_from_png (const std::filesystem::path &png_path, const std::string &frame_name, const LoaderType &loader)
 Loads an animation frame from a PNG file.
 

Detailed Description

Shared helper for loading animation frames from PNG files.

This header provides load_animation_frame_from_png<>(), a template function that encapsulates the common logic for loading an animation frame PNG file and extracting tiles from it. This is used by both:

  • ProjectVanillaAnimImporter (imports vanilla tileset animations as IndexPixel)
  • ProjectTilesetArtifactReader (loads Porytiles or Porymap animation frames as Rgba32 or IndexPixel)

The helper handles:

  1. Loading the PNG file via the provided loader
  2. Calculating width_tiles/height_tiles from image dimensions
  3. Extracting tiles from the image via extract_tiles_from_image()
  4. Creating an AnimFrame with the extracted tiles
  5. Setting the palette on the frame if the image has one

Each caller is responsible for:

  • Adding the frame to their Animation/component data structure
  • Updating AnimParams with dimensions (typically from first frame)

Definition in file anim_frame_loader.hpp.