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
36 FGAPI fg_err fg_create_image(fg_image* pImage,
37 const unsigned pWidth, const unsigned pHeight,
38 const fg_channel_format pFormat, const fg_dtype pType);
39
48 FGAPI fg_err fg_retain_image(fg_image* pOut, fg_image pImage);
49
57 FGAPI fg_err fg_release_image(fg_image pImage);
58
67 FGAPI fg_err fg_set_image_alpha(fg_image pImage, const float pAlpha);
68
77 FGAPI fg_err fg_set_image_aspect_ratio(fg_image pImage, const bool pKeepRatio);
78
87 FGAPI fg_err fg_get_image_width(unsigned *pOut, const fg_image pImage);
88
97 FGAPI fg_err fg_get_image_height(unsigned *pOut, const fg_image pImage);
98
107 FGAPI fg_err fg_get_image_pixelformat(fg_channel_format* pOut, const fg_image pImage);
108
117 FGAPI fg_err fg_get_image_type(fg_dtype* pOut, const fg_image pImage);
118
127 FGAPI fg_err fg_get_pixel_buffer(unsigned* pOut, const fg_image pImage);
128
137 FGAPI fg_err fg_get_image_size(unsigned* pOut, const fg_image pImage);
138
151 FGAPI fg_err fg_render_image(const fg_window pWindow,
152 const fg_image pImage,
153 const int pX, const int pY, const int pWidth, const int pHeight);
154
157 #ifdef __cplusplus
158 }
159 #endif
160
161
162 #ifdef __cplusplus
163
164 namespace forge
165 {
166
167 class Window;
168
174 class Image {
175 private:
176 fg_image mValue;
177
178 public:
189 FGAPI Image(const unsigned pWidth, const unsigned pHeight,
190 const ChannelFormat pFormat=FG_RGBA, const dtype pDataType=f32);
191
197 FGAPI Image(const Image& pOther);
198
207 FGAPI explicit Image(const fg_image pHandle);
208
212 FGAPI ~Image();
213
219 FGAPI void setAlpha(const float pAlpha);
220
226 FGAPI void keepAspectRatio(const bool pKeep);
227
232 FGAPI unsigned width() const;
233
238 FGAPI unsigned height() const;
239
244 FGAPI ChannelFormat pixelFormat() const;
245
250 FGAPI dtype channelType() const;
251
257 FGAPI unsigned pixels() const;
258
264 FGAPI unsigned size() const;
265
275 FGAPI void render(const Window& pWindow,
276 const int pX, const int pY, const int pVPW, const int pVPH) const;
277
281 FGAPI fg_image get() const;
282 };
283
284 }
285
286 #endif
fg_get_image_pixelformat
FGAPI fg_err fg_get_image_pixelformat(fg_channel_format *pOut, const fg_image pImage)
Get the channel format of the image.
forge::Image::Image
FGAPI Image(const unsigned pWidth, const unsigned pHeight, const ChannelFormat pFormat=FG_RGBA, const dtype pDataType=f32)
Creates a Image object.
forge::Image::height
FGAPI unsigned height() const
Get Image height.
fg_set_image_alpha
FGAPI fg_err fg_set_image_alpha(fg_image pImage, const float pAlpha)
Set a global alpha value for rendering the image.
forge::f32
Definition: defines.h:193
forge::Image::pixelFormat
FGAPI ChannelFormat pixelFormat() const
Get Image&#39;s channel format.
FG_RGBA
Four(Red, Green, Blue & Alpha) channels.
Definition: defines.h:113
forge::Image::render
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.
fg_get_image_width
FGAPI fg_err fg_get_image_width(unsigned *pOut, const fg_image pImage)
Get the width of the image.
forge
Definition: chart.h:304
fg_create_image
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.
forge::Image::keepAspectRatio
FGAPI void keepAspectRatio(const bool pKeep)
Set option to inform whether to maintain aspect ratio of original image.
forge::dtype
dtype
Definition: defines.h:188
fg_get_image_height
FGAPI fg_err fg_get_image_height(unsigned *pOut, const fg_image pImage)
Get the height of the image.
fg_channel_format
fg_channel_format
Definition: defines.h:108
forge::Image::size
FGAPI unsigned size() const
Get the image data size in bytes.
FGAPI
#define FGAPI
Definition: defines.h:28
defines.h
fg_retain_image
FGAPI fg_err fg_retain_image(fg_image *pOut, fg_image pImage)
Increment the internal reference counter for image resource.
fg_get_image_size
FGAPI fg_err fg_get_image_size(unsigned *pOut, const fg_image pImage)
Get the image buffer size in bytes.
forge::Image::pixels
FGAPI unsigned pixels() const
Get the resource id of image buffer.
forge::Image::channelType
FGAPI dtype channelType() const
Get Image&#39;s integral data type.
fg_image
void * fg_image
Definition: defines.h:43
forge::Image::~Image
FGAPI ~Image()
Image Destructor.
fg_err
fg_err
Definition: defines.h:49
fg_release_image
FGAPI fg_err fg_release_image(fg_image pImage)
Destroy image object.
fg_get_pixel_buffer
FGAPI fg_err fg_get_pixel_buffer(unsigned *pOut, const fg_image pImage)
Get the image buffer resource identifier.
forge::Image::width
FGAPI unsigned width() const
Get Image width.
forge::Image
Image is plain rendering of an image over the window or sub-region of it.
Definition: image.h:174
forge::Window
Window is where other objects such as Images, Plots etc.
Definition: window.h:300
forge::Image::setAlpha
FGAPI void setAlpha(const float pAlpha)
Set a global alpha value for rendering the image.
fg_window
void * fg_window
Definition: defines.h:40
fg_get_image_type
FGAPI fg_err fg_get_image_type(fg_dtype *pOut, const fg_image pImage)
Get the pixel data type of the image.
fg_dtype
fg_dtype
Definition: defines.h:150
fg_render_image
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.
fg_set_image_aspect_ratio
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.