SUPERNOVA: Add better support of pbm format in create_supernova

The tool was only supporting a very restricted subset of the PBM
format, as written by gimp. Now it should support reading any
PDM file.
This commit is contained in:
Thierry Crozat 2019-05-28 23:39:34 +01:00
parent 96c429dd7c
commit 9ff9264ab0
3 changed files with 77 additions and 29 deletions

View file

@ -21,6 +21,10 @@ void File::write(const void *buffer, int len) {
fwrite(buffer, 1, len, f);
}
bool File::eof() {
return feof(f) != 0;
}
byte File::readByte() {
byte v;
read(&v, sizeof(byte));
@ -39,16 +43,6 @@ uint32 File::readLong() {
return FROM_LE_32(v);
}
void File::readString(char* string, int bufferLength) {
int i = 0;
while (i < bufferLength - 1 && fread(string + i, 1, 1, f) == 1) {
if (string[i] == '\n' || string[i] == 0)
break;
++ i;
}
string[i] = 0;
}
void File::writeByte(byte v) {
write(&v, sizeof(byte));
}