forked from HaikuArchives/ArtPaint
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImage.h
More file actions
153 lines (110 loc) · 3.55 KB
/
Copy pathImage.h
File metadata and controls
153 lines (110 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
* Copyright 2003, Heikki Suhonen
* Distributed under the terms of the MIT License.
*
* Authors:
* Heikki Suhonen <heikki.suhonen@gmail.com>
*
*/
#ifndef IMAGE_H
#define IMAGE_H
#include <InterfaceDefs.h>
#include <List.h>
#include <Region.h>
class BBitmap;
class BFile;
class ImageView;
class Layer;
class Selection;
class UndoEvent;
class UndoQueue;
struct color_entry {
float probability;
int8 value;
};
/*
The Image-class handles the image. It has the following duties:
1. Stores the layers
2. Renders a complete picture out of the layers
3. Allows undo-mechanism to update the layers
4. Calculates thumbnail-images when necessary
5. Makes a dithered image if necessary.
*/
class Image {
BList* layer_list;
Layer** layer_id_list;
// This is the index of active layer in layer_list.
int32 current_layer_index;
int32 next_layer_id;
BBitmap* rendered_image;
BBitmap* thumbnail_image;
BBitmap* dithered_image;
BList* dithered_users;
bool dithered_up_to_date;
// these are the real width and height of canvas in pixels
float image_width;
float image_height;
ImageView* image_view;
UndoQueue* undo_queue;
void CalculateThumbnails();
static int32 calculate_thumbnail_image(void*);
uint32 full_fixed_alpha;
static rgb_color* color_list;
static color_entry* color_candidates;
static int32 color_candidate_users;
int32 number_of_cpus;
static int32 enter_dither(void*);
int32 DoDither(BRect);
static int32 candidate_creator(void*);
static int32 enter_render(void*);
static int32 enter_render_nobg(void*);
int32 DoRender(BRect, bool bg = true);
static int32 enter_render_preview(void*);
int32 DoRenderPreview(BRect, int32);
public:
Image(ImageView*, float, float, UndoQueue*);
~Image();
void Render(bool bg = false);
void Render(BRect, bool bg = false);
void RenderPreview(BRect, int32);
void RenderPreview(BRegion&, int32);
void MultiplyRenderedImagePixels(int32);
bool SetImageSize();
Layer* AddLayer(BBitmap*, Layer*, bool add_to_front,
float layer_transparency_coefficient = 1.0,
BRect* offset = NULL);
bool ChangeActiveLayer(Layer*, int32);
bool ChangeActiveLayer(int32);
bool ChangeLayerPosition(Layer*, int32, int32);
bool ClearCurrentLayer(rgb_color&);
bool ClearLayers(rgb_color&);
bool DuplicateLayer(Layer*, int32);
bool MergeLayers(Layer*, int32, bool merge_with_upper);
bool RemoveLayer(Layer*, int32);
bool ToggleLayerVisibility(Layer*, int32);
Layer* ReturnUpperLayer(Layer*);
Layer* ReturnLowerLayer(Layer*);
status_t InsertLayer(BBitmap* layer_bitmap = NULL);
BList* LayerList() { return layer_list; }
void UpdateImageStructure(UndoEvent*);
void RegisterLayersWithUndo();
BBitmap* ReturnThumbnailImage();
BBitmap* ReturnRenderedImage();
BBitmap* ReturnActiveBitmap();
Layer* ReturnActiveLayer() {
return (Layer*)layer_list->ItemAt(current_layer_index);
}
Layer* ReturnLayerById(int32 id);
int32 ReturnActiveLayerIndex() { return current_layer_index; }
float Width() { return image_width; }
float Height() { return image_height; }
bool ContainsLayer(Layer*);
status_t ReadLayers(BFile&);
int64 WriteLayers(BFile&);
status_t ReadLayersOldStyle(BFile&, int32);
status_t RegisterDitheredUser(void*);
status_t UnregisterDitheredUser(void*);
BBitmap* ReturnDitheredImage() { return dithered_image; }
bool IsDitheredUpToDate() { return dithered_up_to_date; }
};
#endif // IMAGE_H