This is the manual of the library AlSub version 0.1.0
This software doesn't have any warranty, Use it at your own risk!
See in lgpl.txt what you can or can't do with it.
AlSub is a very simple library, planned specially to play subtitles with Allegro, for use in movie players, karaoke, game intros, etc. It can import and export files in .sub format, convert between different rates of frames per second and add more subtitles in real time.
To compile and install, using DJGPP or Mingw32, it's very simple. After unpacking the source files (remember to maintain the directory struct) type:
fix mingw32 (or fix djgpp) make make install
To use the library with your own program, put
#include <alsub.h>
with the other includes, and in the link stage use
gcc -o test.exe test.o -lalsub -lalleg
The class ALSUB_TEXT contain the needed information for each subtitle.
ALSUB_TEXT::ALSUB_TEXT(const int &ini = 0, const int &end = 0, const std::string &text = "");
ALSUB_TEXT::ALSUB_TEXT(const ALSUB_TEXT &ast);
Constructor of class, where you can make a copy of other ALSUB_TEXT, or put the initial frame(ini) and end frame(end) and the string(text).
void ALSUB_TEXT::set(const int &ini = 0, const int &end = 0, const std::string &text = "");
Set the attributes of initial frame (ini), end frame(end) and text(text) of the object.
void ALSUB_TEXT::get(int *ini, int *end, std::string *text);
Copy the attributes initial frame, in ini, end frame, in end, and text, in text, of the object.
bool ALSUB_TEXT::operator ==(const ALSUB_TEXT &ast);
Overload of operator ==, compare the fields initial frame, end frame and the text, returning true if all are equals.
bool ALSUB_TEXT::operator <(const ALSUB_TEXT &ast);
Overload of operator <, compare the initial frame of both, returning true if the initial frame of ast is bigger than the other.
The main class of the library can import and export .sub files and convert between different rates of frame per second.
void ALSUB::insert_text(const ALSUB_TEXT &ast);
void ALSUB::insert_text(const int &ini = 0, const int &end = 0, const std::string &text = "");
Insert in the list of subtitles one object ALSUB_TEXT, or make one with the arguments. The arguments are initial frame(ini) and end frame(end) and the string(text)
void ALSUB::delete_text(const ALSUB_TEXT &ast);
void ALSUB::delete_text(const int &ini = 0, const int &end = 0, const std::string &text = "");
Remove from the list of subtitles the object ALSUB_TEXT passed, or one with the arguments. The arguments are initial frame(ini) and end frame(end) and the string(text)
void ALSUB::update_frame(int frame);
Update the position of the list of subtitles. Call before ALSUB::display().
void ALSUB::reset_frame(void);
void ALSUB::inc_frame(void);
void ALSUB::dec_frame(void);
These methods are to help in the control of frames per second. ALSUB::reset_frame() sets the current frame to 0, ALSUB::inc_frame() increment in one the current frame and ALSUB::dec_frame() decrement in one the current frame.
void ALSUB::display(BITMAP *bmp, const FONT *fonte = font, int x = 0, int y = 0, int c = 0, int borderc = -1, ALSUB_HALIGN halign = LEFT, ALSUB_VALIGN valign = TOP);
Display the current active subtitle in a allegro BITMAP (bmp), using the font (fonte) and in the position x, y. The argument c is the text color, and borderc is the border text color(-1 for transparent). The argument halign is of the ALSUB_HALIGN type and can be LEFT, CENTER or RIGHT, and valign is of ALSUB_VALIGN type and can be TOP, MIDDLE or BOTTOM.
int ALSUB::load(const char *file);
Import a file (file) in .sub format. The current subtitles list is cleared and then the file is loaded. Return 0 if ok, 1 if the file can't be opened.
int ALSUB::save(const char *file);
Export a file (file) in .sub format.
void ALSUB::convert(const float &afps, const float &nfps);
Convert between two different rates of frames per second, where afps is the current rate and nfps is the new rate. Return 0 if ok, 1 if the file can't be opened.
Any critiques or suggestions, e-mail to dudaskank@yahoo.com
No need for a conclusion