allow ppm files as inputs

- only run bmp.magicValid when path ends in bmp
 - remove uneeced header size constants
This commit is contained in:
Luna 2019-11-01 21:43:45 -03:00
parent 91de05d3b1
commit fb0516a1db
2 changed files with 3 additions and 5 deletions

View file

@ -5,9 +5,6 @@ const bmp = @import("bmp_valid.zig");
const plugins = @import("plugin.zig");
/// Approximate size of the BMP header, in bytes.
pub const BMPHeaderSize: usize = 82000;
/// Buffer size for main image copying.
pub const BufferSize: usize = 300000;
@ -284,6 +281,7 @@ pub const Image = struct {
var magic = [2]u8{ 0, 0 };
_ = try file.read(&magic);
if (std.mem.endsWith(u8, self.path, ".bmp"))
try bmp.magicValid(&magic);
}

View file

@ -89,7 +89,7 @@ pub const Runner = struct {
// before loading the file into scritcher. for example, you can start
// krita/gimp and make it export a bmp and while in the program you can
// apply filters, etc.
if (!std.mem.endsWith(u8, load_path, ".bmp")) {
if (!std.mem.endsWith(u8, load_path, ".bmp") and !std.mem.endsWith(u8, load_path, ".ppm")) {
std.debug.warn("Only BMP files are allowed to be loaded.\n");
return RunError.NoBMP;
}