4 #include <fsdk/Types/Format.h>
5 #include <fsdk/Types/Result.h>
6 #include <fsdk/Types/Sizer.h>
7 #include <fsdk/Types/SubImage.h>
305 return map(rect.x, rect.y, rect.width, rect.height);
328 return map(origin.x, origin.y, size.x, size.y);
353 return extract(rect.x, rect.y, rect.width, rect.height);
378 return extract(origin.x, origin.y, size.x, size.y);
438 return convert(dest, origin.x, origin.y, size.x, size.y, format, device);
522 const
Format format) const noexcept;
551 const
Format format) const noexcept;
576 const
Format format) noexcept;
592 const uint32_t sizeInBytes) noexcept;
605 const uint32_t sizeInBytes,
606 const
Format format) noexcept;
624 const uint32_t sizeInBytes,
625 const
Type type) noexcept;
639 const uint32_t sizeInBytes,
641 const
Format format) noexcept;
682 operator bool () const noexcept {
741 return reinterpret_cast<T*
>(
getData());
748 return reinterpret_cast<const T*
>(
getData());
807 return getData() == other.getData();
814 std::swap(
m_data, other.m_data);
815 std::swap(
m_ref, other.m_ref);
816 std::swap(
m_height, other.m_height);
817 std::swap(
m_width, other.m_width);
818 std::swap(
m_format, other.m_format);
819 std::swap(m_residence, other.m_residence);
828 FSDK_API void putPixel(uint32_t x, uint32_t y) noexcept;
876 static const char* toString (
Image::Error error) noexcept {
894 default:
return "Unknown error";
medium compression (only for png or jpg)
#define FSDK_API
Dummy.
Definition: Def.h:27
FSDK_API Result< Error > loadFromMemory(const void *data, const uint32_t sizeInBytes) noexcept
Load image from memory.
float getAspectRatio() const noexcept
Definition: Image.h:767
A structure that encapsulates an action result enumeration.
Definition: Result.h:29
void reset() noexcept
Reset image contents.
Definition: Image.h:824
static FSDK_API void deallocate(void *memory) noexcept
Free memory.
Vector2< int > Point2i
Definition: Vector2.h:292
Rect getRect() const noexcept
Definition: Image.h:790
Type height
Rectangle height.
Definition: Rect.h:16
int m_height
image height.
Definition: Image.h:833
FSDK_API Result< Image::Error > convert(Image &dest, int x, int y, int width, int height, Format format, TargetDevice device=TargetDevice::CPU) const noexcept
Convert image format.
maximum compression level (only for png or jpg)
FSDK_API Result< Error > create(int width, int height, Format format, bool cleanup=true, MemoryResidence residence=MemoryResidence::MemoryCPU) noexcept
Initializes an empty image and preallocates storage buffer of given size.
bool isNull() const noexcept
Definition: Image.h:665
Bad path for saving / loading.
FSDK_API Result< Error > load(const char *path) noexcept
Load image from file.
void * getData() noexcept
Definition: Image.h:727
Format getFormat() const noexcept
Definition: Image.h:774
const void * getData() const noexcept
Definition: Image.h:733
const T * getDataAs() const noexcept
Definition: Image.h:747
FSDK_API Result< Image::Error > saveToMemory(Image::Type type, IArchive *archive, fsdk::Image::ImageCompression additionalFlag=fsdk::Image::ImageCompression::IC_NO_COMPRESSION) const noexcept
Save image to memory buffer.
int getRowSize() const noexcept
Definition: Image.h:752
T * getScanLineAs(int y) noexcept
Get image scanline data.
Definition: Image.h:712
FSDK_API Image extract(int x, int y, int width, int height) const noexcept
Extract a sub image of this image. The new image will have it's own reference count.
FSDK_API Image rescale(float scale) const noexcept
Rescale image keeping proportions.
MemoryResidence
Memory residence.
Definition: Image.h:102
int getHeight() const noexcept
Definition: Image.h:762
Type width
Rectangle width.
Definition: Rect.h:15
Conversion not implemented.
Format m_format
image format (
Definition: Image.h:836
Invalid memory residence.
SubImage map(const Size &size) const noexcept
Map image contents to a given area.
Definition: Image.h:316
bool isSharedWith(const Image &other) const noexcept
Definition: Image.h:806
void * m_data
raw image data.
Definition: Image.h:831
Result< Image::Error > convert(Image &dest, const Size &size, Format format, TargetDevice device=TargetDevice::CPU) const noexcept
Convert image format.
Definition: Image.h:456
int * m_ref
reference counter. nullptr if image does not own data.
Definition: Image.h:832
const T * getScanLineAs(int y) const noexcept
Get image scanline data.
Definition: Image.h:721
FSDK_API int getRefCount() const noexcept
Obtain reference count.
Error during image saving.
FSDK_API SubImage map(int x, int y, int width, int height) const noexcept
Map image contents to a given area.
Image extract(const Point2i &origin, const Size &size) const noexcept
Extract a sub image of this image. The new image will have it's own reference count.
Definition: Image.h:377
static FSDK_API void * allocate(int size) noexcept
Allocate memory.
Type
Supported image types.
Definition: Image.h:42
void swap(Image &other) noexcept
Swap contents with another image.
Definition: Image.h:813
FSDK_API Result< Error > set(int width, int height, Format format, const void *data) noexcept
Initializes an image with provided data. If current image is not empty and it's size and format match...
Error during image loading.
Failed to retain image: it was released in another thread.
int m_width
image width.
Definition: Image.h:834
Image in Cuda device memory.
ImageCompression
Supported compression type is used only for jpg and png types.
Definition: Image.h:65
Image.
Definition: Image.h:37
compression with minimal (or without) quality loss (only for png or jpg image)
T * getDataAs() noexcept
Definition: Image.h:740
FSDK_API int getDataSize() const noexcept
Target Device is not supported for this system.
Image & operator=(const Image &other) noexcept
Assign an other image.
Definition: Image.h:646
FSDK_API int release() noexcept
Decrease reference count.
Image in Host device memory.
no compression (only for png or jpg image)
Result< Image::Error > convert(Image &dest, const Rect &rect, Format format, TargetDevice device=TargetDevice::CPU) const noexcept
Convert image format.
Definition: Image.h:473
Archive interface.
Definition: IObject.h:37
SubImage map(const Point2i &origin, const Size &size) const noexcept
Map image contents to a given area.
Definition: Image.h:327
Image extract(const Size &size) const noexcept
Extract a sub image of this image. The new image will have it's own reference count.
Definition: Image.h:365
FSDK_API Result< Error > loadFromMemoryOfType(const void *data, const uint32_t sizeInBytes, const Type type) noexcept
Load image from memory of specific type.
FSDK_API void * getScanLine(int y) noexcept
Get image scanline data.
Error
Image error codes.
Definition: Image.h:75
bool ownsData() const noexcept
Definition: Image.h:798
Sub Image.
Definition: SubImage.h:10
Result< Image::Error > convert(Image &dest, Format format, TargetDevice device=TargetDevice::CPU) const noexcept
Convert image format.
Definition: Image.h:487
FSDK_API Image() noexcept
Initializes an empty image.
more than medium compression (only for png or jpg)
Error during initialization.
Image clone() const noexcept
Create a copy of this image. The new image will have it's own reference count.
Definition: Image.h:395
FSDK_API Result< Image::Error > save(const char *path, fsdk::Image::ImageCompression additionalFlag=fsdk::Image::ImageCompression::IC_NO_COMPRESSION) const noexcept
Save image.
TargetDevice
Target device that fsdk::Image algorithms will be running on.
Definition: Image.h:54
Image extract(const Rect &rect) const noexcept
Extract a sub image of this image. The new image will have it's own reference count.
Definition: Image.h:352
Helper entity to measure size of dynamic objects in memory.
Definition: Sizer.h:10
FSDK_API int retain() noexcept
Increase reference count.
Vector2< int > Size
Definition: Vector2.h:301
Size getSize() const noexcept
Definition: Image.h:783
Type y
Upper left corner y-coordinate.
Definition: Rect.h:14
int getWidth() const noexcept
Definition: Image.h:757
Type x
Upper left corner x-coordinate.
Definition: Rect.h:13
bool isValid() const noexcept
Definition: Image.h:672
static FSDK_API Result< Error > guessTypeFromMemory(const void *data, const uint32_t sizeInBytes, Type &type) noexcept
Guess type of image written into memory.