image.h
Go to the documentation of this file.
/*******************************************************
* Copyright (c) 2015-2019, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/
#pragma once
#include <fg/defines.h>
#ifdef __cplusplus
extern "C" {
#endif
FGAPI fg_err fg_create_image(fg_image* pImage,
const unsigned pWidth, const unsigned pHeight,
const fg_channel_format pFormat, const fg_dtype pType);
FGAPI fg_err fg_retain_image(fg_image* pOut, fg_image pImage);
FGAPI fg_err fg_release_image(fg_image pImage);
FGAPI fg_err fg_set_image_alpha(fg_image pImage, const float pAlpha);
FGAPI fg_err fg_set_image_aspect_ratio(fg_image pImage, const bool pKeepRatio);
FGAPI fg_err fg_get_image_width(unsigned *pOut, const fg_image pImage);
FGAPI fg_err fg_get_image_height(unsigned *pOut, const fg_image pImage);
FGAPI fg_err fg_get_image_pixelformat(fg_channel_format* pOut, const fg_image pImage);
FGAPI fg_err fg_get_image_type(fg_dtype* pOut, const fg_image pImage);
FGAPI fg_err fg_get_pixel_buffer(unsigned* pOut, const fg_image pImage);
FGAPI fg_err fg_get_image_size(unsigned* pOut, const fg_image pImage);
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);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
namespace forge
{
class Window;
class Image {
private:
fg_image mValue;
public:
FGAPI Image(const unsigned pWidth, const unsigned pHeight,
const ChannelFormat pFormat=FG_RGBA, const dtype pDataType=f32);
FGAPI Image(const Image& pOther);
FGAPI explicit Image(const fg_image pHandle);
FGAPI ~Image();
FGAPI void setAlpha(const float pAlpha);
FGAPI void keepAspectRatio(const bool pKeep);
FGAPI unsigned width() const;
FGAPI unsigned height() const;
FGAPI ChannelFormat pixelFormat() const;
FGAPI dtype channelType() const;
FGAPI unsigned pixels() const;
FGAPI unsigned size() const;
FGAPI void render(const Window& pWindow,
const int pX, const int pY, const int pVPW, const int pVPH) const;
FGAPI fg_image get() const;
};
}
#endif
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.
forge::Image::pixels
FGAPI unsigned pixels() const
Get the resource id of image buffer.
forge::Image::keepAspectRatio
FGAPI void keepAspectRatio(const bool pKeep)
Set option to inform whether to maintain aspect ratio of original image.
forge::Image::Image
FGAPI Image(const Image &pOther)
Copy constructor of Image.
forge::Image::pixelFormat
FGAPI ChannelFormat pixelFormat() const
Get Image's channel format.
forge::Image::get
FGAPI fg_image get() const
Get the handle to internal implementation of Image.
forge::Image::Image
FGAPI Image(const fg_image pHandle)
Construct Image ojbect from fg_image resource handle.
forge::Image::size
FGAPI unsigned size() const
Get the image data size in bytes.
forge::Image::height
FGAPI unsigned height() const
Get Image height.
forge::Image::~Image
FGAPI ~Image()
Image Destructor.
forge::Image::setAlpha
FGAPI void setAlpha(const float pAlpha)
Set a global alpha value for rendering 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::channelType
FGAPI dtype channelType() const
Get Image's integral data type.
forge::Image::width
FGAPI unsigned width() const
Get Image width.
forge::Window
Window is where other objects such as Images, Plots etc.
Definition window.h:300
defines.h
FGAPI
#define FGAPI
Definition defines.h:28
fg_channel_format
fg_channel_format
Definition defines.h:108
FG_RGBA
@ FG_RGBA
Four(Red, Green, Blue & Alpha) channels.
Definition defines.h:113
fg_err
fg_err
Definition defines.h:49
fg_dtype
fg_dtype
Definition defines.h:150
fg_image
void * fg_image
Definition defines.h:43
fg_window
void * fg_window
Definition defines.h:40
fg_retain_image
FGAPI fg_err fg_retain_image(fg_image *pOut, fg_image pImage)
Increment the internal reference counter for image resource.
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.
fg_release_image
FGAPI fg_err fg_release_image(fg_image pImage)
Destroy image object.
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.
fg_get_image_height
FGAPI fg_err fg_get_image_height(unsigned *pOut, const fg_image pImage)
Get the height of the image.
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.
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_get_image_width
FGAPI fg_err fg_get_image_width(unsigned *pOut, const fg_image pImage)
Get the width of the image.
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_get_image_size
FGAPI fg_err fg_get_image_size(unsigned *pOut, const fg_image pImage)
Get the image buffer size in bytes.
fg_get_pixel_buffer
FGAPI fg_err fg_get_pixel_buffer(unsigned *pOut, const fg_image pImage)
Get the image buffer resource identifier.
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
Definition chart.h:305
forge::dtype
dtype
Definition defines.h:188
forge::f32
@ f32
Definition defines.h:193
forge::ChannelFormat
fg_channel_format ChannelFormat
Definition defines.h:181