resonance 1.0.1
Loading...
Searching...
No Matches
ABmpFile Class Reference

Reader and writer for Windows bitmap files. More...

#include <abmpfile.h>

Inheritance diagram for ABmpFile:
Collaboration diagram for ABmpFile:

Public Member Functions

 ABmpFile (FILE *pFile)
 Construct over an open file.
virtual int StartRead ()
 Slot 1.
virtual int ReadFrame (ABitmap &image, int *pbEnd)
 Slot 3.
virtual int Write (const ABitmap &bitmap)
 Slot 5.
Public Member Functions inherited from AGfxFile
 AGfxFile (FILE *pFile)
 Construct over an open file.
virtual void SetUnreadWord (int nWord)
 Set mUnreadWord.
virtual ~AGfxFile ()
 Close the file.

Additional Inherited Members

Static Public Member Functions inherited from AGfxFile
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 inherited from AGfxFile
FILE * mFile
ARect mBounds
int mDuration

Detailed Description

Reader and writer for Windows bitmap files.

Its single public base is AGfxFile at offset zero. Its table at 0x0083d1c0 overrides slots 1, 3, 4, and 5. AGfxFile::Open() allocates 0x3c bytes for it.

The reader accepts a 40 byte information header with one plane at 4, 8, 16, or 24 bits per pixel, uncompressed or run length encoded. A 24 bit file is read into a kABitmapFormatLinear32 bitmap with full alpha. A 16 or 24 bit row has its red and blue fields exchanged, and a 4 bit row has the two nibbles of each byte exchanged, which gives the nibble order ACanvasLin4 uses.

The destructor in slot 4 at 0x0061d4c8 is compiler-generated. It is AGfxFile's inline destructor expanded in place (restoring AGfxFile's table at 0x0083d218 and closing mFile when it is open), followed by the free when the deleting flag is set.

Constructor & Destructor Documentation

◆ ABmpFile()

ABmpFile::ABmpFile ( FILE * pFile)
inlineexplicit

Construct over an open file.

Inline. AGfxFile::Open() compiles it.

Parameters
pFileThe open file.

Member Function Documentation

◆ StartRead()

virtual int ABmpFile::StartRead ( )
virtual

Slot 1.

Read both headers and record the image geometry.

Both headers are read into file-scope buffers first, at 0x008e68e0 and 0x008e68f0. A file type other than BM, an information header size other than 40, a plane count other than one, or a one bit image gives kAGfxFileBadFormat. A negative height marks a top-down file, and mBounds receives the width and the height as the file records them, before the sign is removed.

Returns
An AGfxFileResult code.
Ghidra address:
NTSC-U/C: 0x0061c688
Ghidra address:
PAL: 0x0065d218

Implements AGfxFile.

◆ ReadFrame()

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

Slot 3.

Read the one image the file holds.

A second call reports the end. An unsupported pixel width returns kAGfxFileBadFormat without releasing the palette already read, and a failed read releases the pixel rectangle through the single-object path although the allocation came from the tagged allocator.

Parameters
imageReceives the image and its palette.
pbEndSet to one on a second call.
Returns
An AGfxFileResult code.
Ghidra address:
NTSC-U/C: 0x0061c860
Ghidra address:
PAL: 0x0065d3f0

Implements AGfxFile.

◆ Write()

virtual int ABmpFile::Write ( const ABitmap & bitmap)
virtual

Slot 5.

Write a bitmap as an uncompressed file.

Accepts kABitmapFormatLinear8, kABitmapFormatLinear15, and kABitmapFormatLinear24, and returns kAGfxFileBadFormat for any other format. An eight bit bitmap writes 256 palette entries, zero when the bitmap has no palette. Rows are written bottom-up, each padded to a multiple of four bytes, and neither the 16 nor the 24 bit rows have their red and blue fields exchanged, unlike the reader.

Parameters
bitmapThe bitmap to write.
Returns
An AGfxFileResult code.
Ghidra address:
NTSC-U/C: 0x0061ca78
Ghidra address:
PAL: 0x0065d608

Implements AGfxFile.


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