summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/PPMLoader.h
diff options
context:
space:
mode:
authorLenny Maiorani <lenny@serenityos.org>2022-03-12 11:16:30 -0700
committerAndreas Kling <kling@serenityos.org>2022-03-13 22:35:20 +0100
commit786b02730c88fd0d202e375fc4798bc994699f43 (patch)
treedc4bf176b79ecd92dcafe2c89d6135af9512ca52 /Userland/Libraries/LibGfx/PPMLoader.h
parent5c21f963ff7a11ec160707d1a6f6831af38a3af0 (diff)
downloadserenity-786b02730c88fd0d202e375fc4798bc994699f43.zip
LibGfx: Commonize P[BGP]M file loading contexts
Much of the code in PBM, PGM, and PPM image loaders is common. The contexts are nearly identical. Instead of writing multiple contexts, write 1 with a template argument to pass in the details of the given format.
Diffstat (limited to 'Userland/Libraries/LibGfx/PPMLoader.h')
-rw-r--r--Userland/Libraries/LibGfx/PPMLoader.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGfx/PPMLoader.h b/Userland/Libraries/LibGfx/PPMLoader.h
index 19dc9e7ed8..572e2170d3 100644
--- a/Userland/Libraries/LibGfx/PPMLoader.h
+++ b/Userland/Libraries/LibGfx/PPMLoader.h
@@ -1,16 +1,26 @@
/*
* Copyright (c) 2020, Hüseyin ASLITÜRK <asliturk@hotmail.com>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
+#include <AK/StringView.h>
#include <LibGfx/ImageDecoder.h>
+#include <LibGfx/PortableImageMapLoader.h>
namespace Gfx {
-struct PPMLoadingContext;
+struct PPM {
+ static constexpr auto ascii_magic_number = '3';
+ static constexpr auto binary_magic_number = '6';
+ static constexpr StringView image_type = "PPM";
+ u16 max_val { 0 };
+};
+
+using PPMLoadingContext = PortableImageMapLoadingContext<PPM>;
class PPMImageDecoderPlugin final : public ImageDecoderPlugin {
public: