29 const struct pixel *x = a;
30 const struct pixel *y = b;
31 if (x->
n > y->
n) {
return -1; }
32 if (x->
n < y->
n) {
return 1; }
33 if (x->
e > y->
e) {
return -1; }
34 if (x->
e < y->
e) {
return 1; }
50 float *raw = (
float *) malloc(width * height *
sizeof(
float));
51 glActiveTexture(GL_TEXTURE0 +
TEX_RAW);
52 glGetTexImage(GL_TEXTURE_2D, 0, GL_GREEN, GL_FLOAT, raw);
53 float *data = malloc(width * height *
sizeof(
float));
54 for (
int j = 0;
j < height; ++
j) {
55 for (
int i = 0;
i < width; ++
i) {
56 int ki = (height - 1 -
j) * width +
i;
57 int ko =
j * width +
i;
77 float *raw = (
float *) malloc(width * height *
sizeof(
float));
78 glActiveTexture(GL_TEXTURE0 +
TEX_RAW);
79 glGetTexImage(GL_TEXTURE_2D, 0, GL_RED, GL_FLOAT, raw);
80 float *data = malloc(width * height *
sizeof(
float));
81 for (
int j = 0;
j < height; ++
j) {
82 for (
int i = 0;
i < width; ++
i) {
83 int ki = (height - 1 -
j) * width +
i;
84 int ko =
j * width +
i;
103 unsigned char *
image_erode(
const unsigned char *data,
int width,
int height) {
104 unsigned char *data2 = (
unsigned char *) malloc(width * height);
105 for (
int j = 0;
j < height; ++
j) {
106 for (
int i = 0;
i < width; ++
i) {
107 int k =
j * width +
i;
110 for (
int jj = -1; jj <= 1; ++jj) {
111 for (
int ii = -1; ii <= 1; ++ ii) {
114 if (0 <= iii && iii < width && 0 <= jjj && jjj < height) {
115 int kkk = jjj * width + iii;
116 setcount += data[kkk];
121 data2[k] = totalcount == setcount;
141 struct pixel *pxs = malloc(width * height *
sizeof(
struct pixel));
143 for (
int j = 0;
j < height; ++
j) {
144 for (
int i = 0;
i < width; ++
i) {
145 int k =
j * width +
i;
146 if (glitched[k] > 0.0) {
147 pxs[*count].
e = glitched[k];
148 pxs[*count].
n = iterations[k];
161 enum result_t image_result(
int width,
int height,
double *iterations,
double *exterior,
double *interior,
double *glitch) {
166 double percent = 100.0 / (width * height);
167 float *raw = malloc(width * height * 2 *
sizeof(
float));
168 glActiveTexture(GL_TEXTURE0 +
TEX_RAW);
169 glGetTexImage(GL_TEXTURE_2D, 0, GL_RG, GL_FLOAT, raw);
170 for (
int j = 0;
j < height; ++
j) {
171 for (
int i = 0;
i < width; ++
i) {
172 int k =
j * width +
i;
173 *iterations = fmaxf(*iterations, fabsf(raw[2*k+0]));
174 *exterior += raw[2*k+0] > 0.0;
175 *interior += raw[2*k+0] <= 0.0;
176 *glitch += raw[2*k+1] != 0.0;
180 *exterior *= percent;
181 *interior *= percent;
183 if (*glitch < 0.02) {