Skip to content

Commit 97baeb4

Browse files
committed
Add IImageFormat interface
1 parent edbb4ba commit 97baeb4

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ target_sources(scratchcpp
4848
include/scratchcpp/sprite.h
4949
include/scratchcpp/itimer.h
5050
include/scratchcpp/keyevent.h
51+
include/scratchcpp/iimageformat.h
5152
)
5253

5354
add_library(zip SHARED

include/scratchcpp/iimageformat.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
#pragma once
4+
5+
#include "global.h"
6+
7+
namespace libscratchcpp
8+
{
9+
10+
/*! A typedef for unsigned int. Holds the RGBA values. */
11+
using Rgb = unsigned int;
12+
13+
/*! \brief The IImageFormat class is an interface for image format implementation. */
14+
class LIBSCRATCHCPP_EXPORT IImageFormat
15+
{
16+
public:
17+
virtual ~IImageFormat() { }
18+
19+
/*! Sets the image data (buffer). */
20+
virtual void setData(const char *data) = 0;
21+
22+
/*! Returns the width of the image. */
23+
virtual unsigned int width() const = 0;
24+
25+
/*! Returns the height of the image. */
26+
virtual unsigned int height() const = 0;
27+
28+
/*! Returns the color at the given pixel. */
29+
virtual Rgb colorAt(unsigned int x, unsigned int y, double scale = 1) const = 0;
30+
};
31+
32+
} // namespace libscratchcpp

0 commit comments

Comments
 (0)