-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuffer.h
106 lines (78 loc) · 2.06 KB
/
buffer.h
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
/* Buffer for image data */
#ifndef BUFFER_H
#define BUFFER_H
#ifndef _MSC_VER
#include <SDL2/SDL.h>
#else
#include <SDL.h>
#endif
#include "slice.h"
typedef struct {
SDL_Color *colors;
int len;
int size;
int scroll;
} palette;
enum undoType {
StartUndo,
EndUndo,
PixelUndo,
};
typedef enum undoType undoType;
typedef struct {
int index;
Uint32 oldColor;
Uint32 newColor;
} pixDiff;
struct undo {
struct undo *prev;
struct undo *next;
undoType type;
union {
char batchUndoData;
pixDiff pixUndoData;
} data;
};
typedef struct undo undo;
typedef struct {
StrSlice *name;
unsigned char *filename;
unsigned int zoom;
int panx;
int pany;
int sizex;
int sizey;
unsigned int datachannels;
unsigned char *data;
unsigned char changedp;
unsigned char tool;
unsigned int selcontext;
SDL_Color primary;
SDL_Color secondary;
palette *pal;
undo *undoList;
undo *saveUndo;
} buffer;
palette *defaultPalette();
void addColorToPalette(palette * pal, SDL_Color color);
buffer *makeBuffer(char *name);
buffer *makeBufferFromFile(char *filename);
void setBufferFileName(char *filename, buffer * buf);
void killBuffer(buffer * buf);
SDL_Texture *textureFromBuffer(buffer * buf, SDL_Renderer * rend);
void bufferSetPixel(buffer * buf, int px, int py, SDL_Color color);
void bufferDrawLine(buffer * buf, SDL_Color color, int x0, int y0, int x1, int y1);
void bufferPencil(buffer * buf, int px, int py, SDL_Color color);
int bufferIsDirty(buffer * buf);
void bufferStartUndo(buffer * buf);
void bufferEndUndo(buffer * buf);
void bufferDoUndo(buffer * buf);
void bufferDoRedo(buffer * buf);
void bufferDoFloodFill(buffer * buf, int px, int py, SDL_Color new);
void bufferDoFloodFillDither(buffer * buf, int px, int py, SDL_Color a, SDL_Color b);
void bufferDoRectOutline(buffer * buf, int x1, int y1, int x2, int y2, SDL_Color color);
void bufferDoRectFill(buffer * buf, int x1, int y1, int x2, int y2, SDL_Color color,
SDL_Color border);
SDL_Color bufferGetColorAt(buffer * buf, int x, int y);
buffer *makeNewBuffer(SDL_Renderer * rend, SDL_Texture * font);
#endif