Iridescence 1.00
Embedded Graphic Framework
Loading...
Searching...
No Matches
ds_image.h
1/* Copyright (C) 2017 - 2024, Thornwave Labs Inc - All Rights Reserved.
2 * Unauthorized copying of this file, via any medium is strictly prohibited.
3 * Proprietary and confidential.
4 * Written by Razvan Turiac <razvan.turiac@thornwave.com>
5*/
6
7#ifndef _DS_IMAGE_H
8#define _DS_IMAGE_H
9
10
11#include <ds_view.h>
12
13
17class DsImage: public DsView
18{
19public:
27 DsImage(DsView* parent, const DsPoint &pos = DsPoint(), const DsSize &size = DsSize());
28
29
42 DsImage(DsView* parent, const DsPoint &pos, const DsSize &size, const void* png, size_t png_size, bool alpha_only, DsColor color = OPAQUE, const DsAlignment &alignment = DS_ALIGN_CENTER);
43
44
55 DsImage(DsView* parent, const DsPoint &pos, const DsSize &size, const void* jpg, size_t jpg_size, const DsAlignment &alignment = DS_ALIGN_CENTER);
56
57
68 DsImage(DsView* parent, const DsPoint &pos, const DsSize &size, const DsSurface &surface, DsColor color = OPAQUE, const DsAlignment &alignment = DS_ALIGN_CENTER);
69
70
75
76
84 void setImagePng(const void* png, size_t png_size, bool alpha_only = false, DsColor color = OPAQUE);
85
86
92 void setImageJpg(const void* jpg, size_t jpg_size);
93
94
101 void setImage(const DsSurface* surface, DsColor color = OPAQUE);
102
103
109
110
116 void setAlignment(const DsAlignment &alignment);
117
118private:
119 void onPaint(DsRenderer &renderer) override final;
120 void onPaintOver(DsRenderer &renderer) override final;
121 DsSize fitContent(void) override final;
122
123 DsAlignment mAlignment;
124
125 //main image
126 const DsSurface* mImageSurface;
127 bool mIsSurfaceFreeable;
128 DsColor mImageColor; //for alpha only images
129 };
130
131
132
133#endif
DsAlignment is a class representing both horizontal and vertical alignment type.
Definition ds_types.h:130
DsColor is a class that represents a 4 channel color (Alpha, Red, Green, Blue).
Definition ds_color.h:53
DsImage is a class that implements a view capable of displaying an image.
Definition ds_image.h:18
void setImageJpg(const void *jpg, size_t jpg_size)
Initializes the image using raw JPEG data.
void setImageColor(DsColor color)
Sets the color used for drawing images that contain the alpha channel only (A8 type).
DsImage(DsView *parent, const DsPoint &pos, const DsSize &size, const DsSurface &surface, DsColor color=OPAQUE, const DsAlignment &alignment=DS_ALIGN_CENTER)
Creates a DsImage view using a surface.
DsImage(DsView *parent, const DsPoint &pos=DsPoint(), const DsSize &size=DsSize())
Creates a DsImage view without any surface attached (no content).
void setImage(const DsSurface *surface, DsColor color=OPAQUE)
Initializes the image using a surface.
DsImage(DsView *parent, const DsPoint &pos, const DsSize &size, const void *jpg, size_t jpg_size, const DsAlignment &alignment=DS_ALIGN_CENTER)
Creates a DsImage view using raw JPEG data.
DsImage(DsView *parent, const DsPoint &pos, const DsSize &size, const void *png, size_t png_size, bool alpha_only, DsColor color=OPAQUE, const DsAlignment &alignment=DS_ALIGN_CENTER)
Creates a DsImage view using raw PNG data.
void setImagePng(const void *png, size_t png_size, bool alpha_only=false, DsColor color=OPAQUE)
Initializes the image using PNG data.
void setAlignment(const DsAlignment &alignment)
Sets the alignment used for the image inside the view.
DsPoint is a class that represents the X and Y 2D coordinates of a point as integer numbers.
Definition ds_geometry.h:24
DsRenderer is a class that implements all the drawing operations.
Definition ds_renderer.h:42
DsSize is class that represents the 2D size of a graphic object (width, height) as integer values.
Definition ds_geometry.h:780
DsSurface is a class that represents a drawing surface.
Definition ds_surface.h:30
DsView is a base class that represents any view on the screen.
Definition ds_view.h:40