Ocean
Loading...
Searching...
No Matches
media/Image.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_IMAGE_H
9#define META_OCEAN_MEDIA_IMAGE_H
10
11#include "ocean/media/Media.h"
13
14namespace Ocean
15{
16
17namespace Media
18{
19
20// Forward declaration.
21class Image;
22
23/**
24 * Definition of a smart medium reference holding an image object.
25 * @see SmartMediumRef, Image.
26 * @ingroup media
27 */
29
30/**
31 * This class is the base class for all images.
32 * An image holds one single frame only and gets the image framebuffer data from e.g. an image file.<br>
33 * @see Movie, LiveVideo, PixelImage
34 * @ingroup media
35 */
36class OCEAN_MEDIA_EXPORT Image : public virtual FrameMedium
37{
38 public:
39
40 /**
41 * Definition of a class holding properties.
42 * Note: Depending on the image format, a provided property like a quality value may not have any impact, e.g., png images do not support a loosely compression.
43 */
45 {
46 public:
47
48 /**
49 * Default constructor.
50 */
51 Properties() = default;
52
53 /**
54 * Creates a new properties object.
55 * @param quality The quality to be used, with range [0, 1], -1 if unknown or default quality
56 * @param colorProfileName The optional name of the color profile, e.g., "sRGB IEC61966-2.1", or "Adobe RGB (1998)"
57 */
58 explicit inline Properties(const float quality, std::string&& colorProfileName = std::string());
59
60 /**
61 * Returns whether this object holds valid parameters.
62 * @return True, if so
63 */
64 inline bool isValid() const;
65
66 public:
67
68 /// The quality to be used when encoding or decoding an image, with range [0, 1], -1 if default quality or unknown.
69 float quality_ = -1.0f;
70
71 /// The name of the color profile, empty if unknown.
72 std::string colorProfileName_;
73 };
74
75 protected:
76
77 /**
78 * Creates a new image by a given url.
79 * @param url Url of the image
80 */
81 explicit Image(const std::string& url);
82};
83
84inline Image::Properties::Properties(const float quality, std::string&& colorProfileName) :
85 quality_(quality),
86 colorProfileName_(std::move(colorProfileName))
87{
88 ocean_assert(isValid());
89}
90
91inline bool Image::Properties::isValid() const
92{
93 return quality_ == -1.0f || (quality_ >= 0.0f && quality_ <= 1.0f);
94}
95
96}
97
98}
99
100#endif // META_OCEAN_MEDIA_IMAGE_H
This is the base class for all frame mediums.
Definition FrameMedium.h:53
Definition of a class holding properties.
Definition media/Image.h:45
Properties()=default
Default constructor.
bool isValid() const
Returns whether this object holds valid parameters.
Definition media/Image.h:91
std::string colorProfileName_
The name of the color profile, empty if unknown.
Definition media/Image.h:72
This class is the base class for all images.
Definition media/Image.h:37
Image(const std::string &url)
Creates a new image by a given url.
This class implements a smart medium reference.
Definition MediumRef.h:33
SmartMediumRef< Image > ImageRef
Definition of a smart medium reference holding an image object.
Definition media/Image.h:28
The namespace covering the entire Ocean framework.
Definition Accessor.h:15