resonance 1.0.1
Loading...
Searching...
No Matches
agfxfile.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdio.h>
4
5#include "rndartt/arect.h"
6
7class ABitmap;
8
17
33class AGfxFile {
34public:
52 static AGfxFile *Open(const char *pszPath, int *pnError, bool bRead);
53
65 static int Write(const char *pszPath, const ABitmap &bitmap);
66
74 explicit AGfxFile(FILE *pFile) : mFile(pFile), mUnreadWord(-1) {
75 }
76
82 virtual int StartRead() = 0;
83
94 virtual void SetUnreadWord(int nWord) {
95 mUnreadWord = nWord;
96 }
97
105 virtual int ReadFrame(ABitmap &image, int *pbEnd) = 0;
106
116 virtual ~AGfxFile() {
117 if (mFile != nullptr) {
118 fclose(mFile);
119 }
120 }
121
128 virtual int Write(const ABitmap &bitmap) = 0;
129
130protected:
131 FILE *mFile; // +0x00 The open file.
132
133private:
134 int mUnreadWord; // +0x04 Set to -1 on construction and by SetUnreadWord().
135
136protected:
137 ARect mBounds; // +0x08 The image rectangle the last header or image descriptor gave.
138 int mDuration; // +0x10 Display time accumulated from GIF graphic control blocks, in ms.
139};
140
153int GrabExt(const char *pszPath);
AGfxFileResult
Results the AGfxFile members return.
Definition agfxfile.h:10
@ kAGfxFileUnsupported
Definition agfxfile.h:14
@ kAGfxFileOpenFailed
Definition agfxfile.h:13
@ kAGfxFileBadFormat
Definition agfxfile.h:15
@ kAGfxFileNoMemory
Definition agfxfile.h:12
@ kAGfxFileOk
Definition agfxfile.h:11
int GrabExt(const char *pszPath)
Return the first three characters after the last full stop of a path, packed into a word.
Description of a pixel rectangle, its layout, and its palette.
Definition abitmap.h:95
virtual int StartRead()=0
Read the file header.
virtual ~AGfxFile()
Close the file.
Definition agfxfile.h:116
virtual int Write(const ABitmap &bitmap)=0
Write a bitmap to the file.
virtual void SetUnreadWord(int nWord)
Set mUnreadWord.
Definition agfxfile.h:94
static AGfxFile * Open(const char *pszPath, int *pnError, bool bRead)
Open an image file and construct the reader for its extension.
AGfxFile(FILE *pFile)
Construct over an open file.
Definition agfxfile.h:74
ARect mBounds
Definition agfxfile.h:137
virtual int ReadFrame(ABitmap &image, int *pbEnd)=0
Read the next image in the file.
FILE * mFile
Definition agfxfile.h:131
static int Write(const char *pszPath, const ABitmap &bitmap)
Write a bitmap to a file in the format its extension selects.
int mDuration
Definition agfxfile.h:138
Half open rectangle of pixel coordinates.
Definition arect.h:25