Ocean
ImageGif.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_MEDIA_OPEN_IMAGE_LIBRARIES_OIL_IMAGE_GIF_H
9 #define META_OCEAN_MEDIA_OPEN_IMAGE_LIBRARIES_OIL_IMAGE_GIF_H
10 
12 
13 #include "ocean/base/Frame.h"
14 
15 namespace Ocean
16 {
17 
18 namespace Media
19 {
20 
21 namespace OpenImageLibraries
22 {
23 
24 /**
25  * This class implements read and write functions for Gif images.
26  * @ingroup mediaoil
27  */
28 class OCEAN_MEDIA_OIL_EXPORT ImageGif
29 {
30  protected:
31 
32  /// Forward declaration.
33  class SourceBuffer;
34 
35  public:
36 
37  /**
38  * Decodes a GIF image from a given binary buffer.
39  * @param buffer The buffer from which the image will be loaded, must be valid
40  * @param size The size of the given buffer in bytes, with range [1, infinity)
41  * @param maximalImages The maximal number of images that will be returned, with range [0, infinity), 0 to return all images
42  * @return The frames containing the image information, an invalid frame if the image could not be loaded
43  */
44  static Frames decodeImages(const void* buffer, const size_t size, const size_t maximalImages = 0u);
45 
46  /**
47  * Reads/loads all images from a specified gif file.
48  * @param filename The name of the file from which the image will be loaded, must be valid
49  * @param maximalImages The maximal number of images that will be returned, with range [0, infinity), 0 to return all images
50  * @return The frame containing the image information, an invalid frame if the image could not be loaded
51  * @see writeImage().
52  */
53  static Frames readImages(const std::string& filename, const size_t maximalImages = 0u);
54 
55  protected:
56 
57  /**
58  * Verifies whether the provided GIF is valid or corrupt.
59  * @param buffer The buffer from which the image will be loaded, must be valid
60  * @param size The size of the given buffer in bytes, with range [1, infinity)
61  * @return True, if the GIF is valid
62  */
63  static bool verifyGif(const void* buffer, const size_t size);
64 };
65 
66 }
67 
68 }
69 
70 }
71 
72 #endif // META_OCEAN_MEDIA_OPEN_IMAGE_LIBRARIES_OIL_IMAGE_GIF_H
This class implements read and write functions for Gif images.
Definition: ImageGif.h:29
static Frames readImages(const std::string &filename, const size_t maximalImages=0u)
Reads/loads all images from a specified gif file.
static Frames decodeImages(const void *buffer, const size_t size, const size_t maximalImages=0u)
Decodes a GIF image from a given binary buffer.
static bool verifyGif(const void *buffer, const size_t size)
Verifies whether the provided GIF is valid or corrupt.
std::vector< Frame > Frames
Definition of a vector holding padding frames.
Definition: Frame.h:1755
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15