CVB++ 14.0
jpeg_converter.hpp
1#pragma once
2
3#include "../_cexports/c_webstreaming.h"
4#include "converter.hpp"
5
6namespace Cvb
7{
8
9CVB_BEGIN_INLINE_NS
10
11namespace WebStreaming
12{
13
21 : public Converter
22{
23 private:
24
25 struct PrivateTag {};
26
27 public:
28
30
35 {
36 return Internal::DoResCallShareOut<JPEGConverter>([&](void*& handle)
37 {
38 return CVB_CALL_CAPI(CVWSCreateConverter(CExports::CVWSCT_Jpeg, handle));
39 });
40 }
41
42 template<class T>
43 static JPEGConverterPtr FromHandle(HandleGuard<Converter>&& guard)
44 {
45 static_assert(std::is_same<JPEGConverter, T>::value, "CVB: T must be JPEGConverter");
46 if (!guard.Handle())
47 throw std::runtime_error("converter handle invalid");
48 return std::make_shared<T>(std::move(guard), PrivateTag{});
49 }
50
51 JPEGConverter(HandleGuard<Converter>&& guard, PrivateTag) noexcept
52 : Converter(std::move(guard))
53 {
54 }
55
57
61 int Scale() const
62 {
63 CExports::cvbint64_t value;
64 CVB_CALL_CAPI_CHECKED(CVWSGetPropertyAsInteger(Handle(), CExports::CVWSCP_JPEGScale, value));
65 return static_cast<int>(value);
66 }
67
69
75 void SetScale(int scale)
76 {
77 CVB_CALL_CAPI_CHECKED(CVWSSetPropertyAsInteger(Handle(), CExports::CVWSCP_JPEGScale, static_cast<CExports::cvbint64_t>(scale)));
78 }
79
81
85 int Quality() const
86 {
87 CExports::cvbint64_t value;
88 CVB_CALL_CAPI_CHECKED(CVWSGetPropertyAsInteger(Handle(), CExports::CVWSCP_JPEGQualityLevel, value));
89 return static_cast<int>(value);
90 }
91
93
99 void SetQuality(int quality)
100 {
101 CVB_CALL_CAPI_CHECKED(CVWSSetPropertyAsInteger(Handle(), CExports::CVWSCP_JPEGQualityLevel, static_cast<CExports::cvbint64_t>(quality)));
102 }
103
104
105};
106
107}
108
109CVB_END_INLINE_NS
110
111}
A converter object.
Definition: converter.hpp:29
void * Handle() const noexcept
Returns C-API style handle to Converter Object.
Definition: converter.hpp:41
A JPEG converter object.
Definition: jpeg_converter.hpp:22
void SetQuality(int quality)
Set the quality of the JPEG conversion.
Definition: jpeg_converter.hpp:99
void SetScale(int scale)
Set the scale of the JPEG conversion.
Definition: jpeg_converter.hpp:75
int Scale() const
Get the scale of the JPEG conversion.
Definition: jpeg_converter.hpp:61
static JPEGConverterPtr Create()
Creates a new JPEG converter.
Definition: jpeg_converter.hpp:34
int Quality() const
Get the quality of the JPEG conversion.
Definition: jpeg_converter.hpp:85
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24