resonance 1.0.1
Loading...
Searching...
No Matches
AGfxFile Class Referenceabstract

Image file reader and writer, one subclass per file format. More...

#include <agfxfile.h>

Inheritance diagram for AGfxFile:
Collaboration diagram for AGfxFile:

Public Member Functions

 AGfxFile (FILE *pFile)
 Construct over an open file.
virtual int StartRead ()=0
 Read the file header.
virtual void SetUnreadWord (int nWord)
 Set mUnreadWord.
virtual int ReadFrame (ABitmap &image, int *pbEnd)=0
 Read the next image in the file.
virtual ~AGfxFile ()
 Close the file.
virtual int Write (const ABitmap &bitmap)=0
 Write a bitmap to the file.

Static Public Member Functions

static AGfxFile * Open (const char *pszPath, int *pnError, bool bRead)
 Open an image file and construct the reader for its extension.
static int Write (const char *pszPath, const ABitmap &bitmap)
 Write a bitmap to a file in the format its extension selects.

Protected Attributes

FILE * mFile
ARect mBounds
int mDuration

Detailed Description

Image file reader and writer, one subclass per file format.

Its RTTI descriptor lacks a base class. ABmpFile, ATgaFile, and AGifFile derive from it. The virtual function table pointer sits after the data members at offset 0x14, and the object is 0x18 bytes, the size AGifFile allocates with no added member.

The table has six slots. Slot 0 is the type function, and slots 1, 3, and 5 point at the shared pure virtual stub. Slot 2 and the destructor at slot 4 are inline, so every translation unit that needs the table emits its own copy of it, at 0x0083d218, 0x0083d928, and 0x0083fe28.

mFile and mDuration are written by the subclasses and mBounds by their header readers, so all three are protected. mUnreadWord is written only by Open() and SetUnreadWord(), and no reader of it was located.

Constructor & Destructor Documentation

◆ AGfxFile()

AGfxFile::AGfxFile ( FILE * pFile)
inlineexplicit

Construct over an open file.

Inline. Open() compiles it for every subclass.

Parameters
pFileThe open file.

◆ ~AGfxFile()

virtual AGfxFile::~AGfxFile ( )
inlinevirtual

Close the file.

Inline. Each subclass destructor is the same body emitted again, at 0x0061d4c8, 0x00620408, and 0x0062b5f8.

Ghidra address:
NTSC-U/C: 0x0061d6c0
Ghidra address:
PAL: 0x0065e250

Member Function Documentation

◆ Open()

AGfxFile * AGfxFile::Open ( const char * pszPath,
int * pnError,
bool bRead )
static

Open an image file and construct the reader for its extension.

The extension selects the class through GrabExt(): BMP, DIB, and RLE give ABmpFile, TGA gives ATgaFile, and GIF gives AGifFile. Each is allocated through the plain allocator and receives the open file.

An unrecognised extension retains the null result and then writes mDuration through it, dereferencing null. The open file is not closed. Write() is the one caller.

Parameters
pszPathThe file to open.
pnErrorReceives kAGfxFileOk, or kAGfxFileOpenFailed when the file cannot be opened.
bReadTrue to open for reading, false to open for writing.
Returns
The reader, or null when the file cannot be opened.
Ghidra address:
NTSC-U/C: 0x005f9bc8
Ghidra address:
PAL: 0x0063a8d8

◆ Write() [1/2]

int AGfxFile::Write ( const char * pszPath,
const ABitmap & bitmap )
static

Write a bitmap to a file in the format its extension selects.

Rnd::VRAM::Screendump() is the one caller.

Parameters
pszPathThe file to write.
bitmapThe bitmap to write.
Returns
An AGfxFileResult code.
Ghidra address:
NTSC-U/C: 0x005f9d18
Ghidra address:
PAL: 0x0063aa28

◆ StartRead()

virtual int AGfxFile::StartRead ( )
pure virtual

Read the file header.

Returns
An AGfxFileResult code.

Implemented in ABmpFile, AGifFile, and ATgaFile.

◆ SetUnreadWord()

virtual void AGfxFile::SetUnreadWord ( int nWord)
inlinevirtual

Set mUnreadWord.

Inline, emitted once at 0x0061d4c0. No reader of the word was located, so its meaning is not recovered.

Parameters
nWordThe value to store.
Ghidra address:
NTSC-U/C: 0x0061d4c0
Ghidra address:
PAL: 0x0065e050

◆ ReadFrame()

virtual int AGfxFile::ReadFrame ( ABitmap & image,
int * pbEnd )
pure virtual

Read the next image in the file.

Parameters
imageReceives the image, with a freshly allocated pixel rectangle.
pbEndSet to one when the file holds no further image.
Returns
An AGfxFileResult code.

Implemented in ABmpFile, AGifFile, and ATgaFile.

◆ Write() [2/2]

virtual int AGfxFile::Write ( const ABitmap & bitmap)
pure virtual

Write a bitmap to the file.

Parameters
bitmapThe bitmap to write.
Returns
An AGfxFileResult code.

Implemented in ABmpFile, AGifFile, and ATgaFile.

Member Data Documentation

◆ mFile

FILE* AGfxFile::mFile
protected

◆ mBounds

ARect AGfxFile::mBounds
protected

◆ mDuration

int AGfxFile::mDuration
protected

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