Forge
image.h
Go to the documentation of this file.
1 /*******************************************************
2  * Copyright (c) 2015-2019, ArrayFire
3  * All rights reserved.
4  *
5  * This file is distributed under 3-clause BSD license.
6  * The complete license agreement can be obtained at:
7  * http://arrayfire.com/licenses/BSD-3-Clause
8  ********************************************************/
9 
10 #pragma once
11 
12 #include <fg/defines.h>
13 
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
37  const unsigned pWidth, const unsigned pHeight,
38  const fg_channel_format pFormat, const fg_dtype pType);
39 
48 
57 FGAPI fg_err fg_set_image_alpha(fg_image pImage, const float pAlpha);
58 
67 FGAPI fg_err fg_set_image_aspect_ratio(fg_image pImage, const bool pKeepRatio);
68 
77 FGAPI fg_err fg_get_image_width(unsigned *pOut, const fg_image pImage);
78 
87 FGAPI fg_err fg_get_image_height(unsigned *pOut, const fg_image pImage);
88 
98 
107 FGAPI fg_err fg_get_image_type(fg_dtype* pOut, const fg_image pImage);
108 
117 FGAPI fg_err fg_get_pixel_buffer(unsigned* pOut, const fg_image pImage);
118 
127 FGAPI fg_err fg_get_image_size(unsigned* pOut, const fg_image pImage);
128 
141 FGAPI fg_err fg_render_image(const fg_window pWindow,
142  const fg_image pImage,
143  const int pX, const int pY, const int pWidth, const int pHeight);
144 
147 #ifdef __cplusplus
148 }
149 #endif
150 
151 
152 #ifdef __cplusplus
153 
154 namespace forge
155 {
156 
157 class Window;
158 
164 class Image {
165  private:
166  fg_image mValue;
167 
168  public:
179  FGAPI Image(const unsigned pWidth, const unsigned pHeight,
180  const ChannelFormat pFormat=FG_RGBA, const dtype pDataType=f32);
181 
187  FGAPI Image(const Image& pOther);
188 
192  FGAPI ~Image();
193 
199  FGAPI void setAlpha(const float pAlpha);
200 
206  FGAPI void keepAspectRatio(const bool pKeep);
207 
212  FGAPI unsigned width() const;
213 
218  FGAPI unsigned height() const;
219 
225 
230  FGAPI dtype channelType() const;
231 
237  FGAPI unsigned pixels() const;
238 
244  FGAPI unsigned size() const;
245 
255  FGAPI void render(const Window& pWindow,
256  const int pX, const int pY, const int pVPW, const int pVPH) const;
257 
261  FGAPI fg_image get() const;
262 };
263 
264 }
265 
266 #endif
FGAPI fg_err fg_get_image_pixelformat(fg_channel_format *pOut, const fg_image pImage)
Get the channel format of the image.
FGAPI Image(const unsigned pWidth, const unsigned pHeight, const ChannelFormat pFormat=FG_RGBA, const dtype pDataType=f32)
Creates a Image object.
FGAPI unsigned height() const
Get Image height.
FGAPI fg_err fg_set_image_alpha(fg_image pImage, const float pAlpha)
Set a global alpha value for rendering the image.
Definition: defines.h:194
FGAPI ChannelFormat pixelFormat() const
Get Image&#39;s channel format.
Four(Red, Green, Blue & Alpha) channels.
Definition: defines.h:113
FGAPI void render(const Window &pWindow, const int pX, const int pY, const int pVPW, const int pVPH) const
Render the image to given window.
FGAPI fg_err fg_get_image_width(unsigned *pOut, const fg_image pImage)
Get the width of the image.
Definition: chart.h:231
FGAPI fg_err fg_create_image(fg_image *pImage, const unsigned pWidth, const unsigned pHeight, const fg_channel_format pFormat, const fg_dtype pType)
Create a Image object.
FGAPI fg_err fg_destroy_image(fg_image pImage)
Destroy image object.
FGAPI void keepAspectRatio(const bool pKeep)
Set option to inform whether to maintain aspect ratio of original image.
dtype
Definition: defines.h:189
FGAPI fg_err fg_get_image_height(unsigned *pOut, const fg_image pImage)
Get the height of the image.
fg_channel_format
Definition: defines.h:108
FGAPI unsigned size() const
Get the image data size in bytes.
#define FGAPI
Definition: defines.h:28
FGAPI fg_err fg_get_image_size(unsigned *pOut, const fg_image pImage)
Get the image buffer size in bytes.
FGAPI unsigned pixels() const
Get the resource id of image buffer.
FGAPI dtype channelType() const
Get Image&#39;s integral data type.
void * fg_image
Definition: defines.h:43
FGAPI ~Image()
Image Destructor.
fg_err
Definition: defines.h:49
FGAPI fg_err fg_get_pixel_buffer(unsigned *pOut, const fg_image pImage)
Get the image buffer resource identifier.
FGAPI unsigned width() const
Get Image width.
Image is plain rendering of an image over the window or sub-region of it.
Definition: image.h:164
Window is where other objects such as Images, Plots etc.
Definition: window.h:296
FGAPI void setAlpha(const float pAlpha)
Set a global alpha value for rendering the image.
void * fg_window
Definition: defines.h:40
FGAPI fg_err fg_get_image_type(fg_dtype *pOut, const fg_image pImage)
Get the pixel data type of the image.
fg_dtype
Definition: defines.h:150
FGAPI fg_err fg_render_image(const fg_window pWindow, const fg_image pImage, const int pX, const int pY, const int pWidth, const int pHeight)
Render the image to given window.
FGAPI fg_err fg_set_image_aspect_ratio(fg_image pImage, const bool pKeepRatio)
Set option to inform whether to maintain aspect ratio of original image.