pixel_converter.h
1 /*
2 ** UICore
3 ** Copyright (c) 1997-2015 The UICore Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries UICore may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 ** Mark Page
28 */
29 
30 #pragma once
31 
32 #include <memory>
33 #include "../../Core/Math/vec4.h"
34 #include "texture_format.h"
35 
36 namespace uicore
37 {
40  {
41  public:
43  static std::shared_ptr<PixelConverter> create();
44 
46  virtual bool premultiply_alpha() const = 0;
47 
49  virtual bool flip_vertical() const = 0;
50 
52  virtual float gamma() const = 0;
53 
55  virtual Vec4i swizzle() const = 0;
56 
58  virtual bool input_is_ycrcb() const = 0;
59 
61  virtual bool output_is_ycrcb() const = 0;
62 
66  virtual void set_premultiply_alpha(bool enable) = 0;
67 
71  virtual void set_flip_vertical(bool enable) = 0;
72 
76  virtual void set_gamma(float gamma) = 0;
77 
81  virtual void set_swizzle(const Vec4i &swizzle) = 0;
82  void set_swizzle(int red_source, int green_source, int blue_source, int alpha_source) { set_swizzle(Vec4i(red_source, green_source, blue_source, alpha_source)); }
83 
85  virtual void set_input_is_ycrcb(bool enable) = 0;
86 
88  virtual void set_output_is_ycrcb(bool enable) = 0;
89 
91  virtual void convert(void *output, int output_pitch, TextureFormat output_format, const void *input, int input_pitch, TextureFormat input_format, int width, int height) = 0;
92  };
93 
94  typedef std::shared_ptr<PixelConverter> PixelConverterPtr;
95 }
virtual float gamma() const =0
Returns the gamma setting.
virtual void set_output_is_ycrcb(bool enable)=0
Converts to JPEG JFIF YCrCb.
virtual Vec4i swizzle() const =0
Returns the input channel used for each output channel.
virtual void set_premultiply_alpha(bool enable)=0
Set the premultiply alpha setting.
virtual void set_swizzle(const Vec4i &swizzle)=0
Set the input channel used for each output channel.
virtual void set_gamma(float gamma)=0
Set the gamma applied when converting.
std::shared_ptr< PixelConverter > PixelConverterPtr
Definition: pixel_buffer.h:48
TextureFormat
Texture format.
Definition: texture_format.h:35
virtual void convert(void *output, int output_pitch, TextureFormat output_format, const void *input, int input_pitch, TextureFormat input_format, int width, int height)=0
Convert some pixel data.
virtual bool input_is_ycrcb() const =0
Returns the JPEG JFIF YCrCb input setting.
void set_swizzle(int red_source, int green_source, int blue_source, int alpha_source)
Definition: pixel_converter.h:82
Vec4< int > Vec4i
Definition: vec4.h:385
virtual void set_flip_vertical(bool enable)=0
Set the flip vertical setting.
virtual void set_input_is_ycrcb(bool enable)=0
Converts from JPEG JFIF YCrCb.
virtual bool output_is_ycrcb() const =0
Returns the JPEG JFIF YCrCb output setting.
Pixel format converter class.
Definition: pixel_converter.h:39
static std::shared_ptr< PixelConverter > create()
Constructs a pixel format converter.
virtual bool premultiply_alpha() const =0
Returns the premultiply alpha setting.
Definition: Application/application.h:35
4D vector
Definition: size.h:44
virtual bool flip_vertical() const =0
Returns the flip vertical setting.