add missing consts
This commit is contained in:
parent
e0e4bd4d86
commit
126ec22867
@ -258,32 +258,32 @@ int stbi_write_tga(char const *filename, int x, int y, int comp, const void *dat
|
|||||||
writef(f, "111 221 2222 11", 0,0,format, 0,0,0, 0,0,x,y, 24+8*has_alpha, 8*has_alpha);
|
writef(f, "111 221 2222 11", 0,0,format, 0,0,0, 0,0,x,y, 24+8*has_alpha, 8*has_alpha);
|
||||||
|
|
||||||
for (j = y - 1; j >= 0; --j) {
|
for (j = y - 1; j >= 0; --j) {
|
||||||
unsigned char *line = (unsigned char *) data + j * x * comp;
|
const unsigned char *row = (unsigned char *) data + j * x * comp;
|
||||||
int run;
|
int len;
|
||||||
|
|
||||||
for (i = 0; i < x; i += run) {
|
for (i = 0; i < x; i += len) {
|
||||||
unsigned char *first = line + i * comp;
|
const unsigned char *begin = row + i * comp;
|
||||||
int diff = 1;
|
int diff = 1;
|
||||||
run = 1;
|
len = 1;
|
||||||
|
|
||||||
if (i < x - 1) {
|
if (i < x - 1) {
|
||||||
++run;
|
++len;
|
||||||
diff = memcmp(first, line + (i + 1) * comp, comp);
|
diff = memcmp(begin, row + (i + 1) * comp, comp);
|
||||||
if (diff) {
|
if (diff) {
|
||||||
unsigned char *next = first;
|
const unsigned char *prev = begin;
|
||||||
for (k = i + 2; k < x && run < 128; ++k) {
|
for (k = i + 2; k < x && len < 128; ++k) {
|
||||||
if (memcmp(next, line + k * comp, comp)) {
|
if (memcmp(prev, row + k * comp, comp)) {
|
||||||
next += comp;
|
prev += comp;
|
||||||
++run;
|
++len;
|
||||||
} else {
|
} else {
|
||||||
--run;
|
--len;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (k = i + 2; k < x && run < 128; ++k) {
|
for (k = i + 2; k < x && len < 128; ++k) {
|
||||||
if (!memcmp(first, line + k * comp, comp)) {
|
if (!memcmp(begin, row + k * comp, comp)) {
|
||||||
++run;
|
++len;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -292,15 +292,15 @@ int stbi_write_tga(char const *filename, int x, int y, int comp, const void *dat
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (diff) {
|
if (diff) {
|
||||||
unsigned char header = (unsigned char) (run - 1);
|
unsigned char header = (unsigned char) (len - 1);
|
||||||
fwrite(&header, 1, 1, f);
|
fwrite(&header, 1, 1, f);
|
||||||
for (k = 0; k < run; ++k) {
|
for (k = 0; k < len; ++k) {
|
||||||
write_pixel(f, -1, comp, has_alpha, 0, first + k * comp);
|
write_pixel(f, -1, comp, has_alpha, 0, begin + k * comp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unsigned char header = (unsigned char) (run - 1) | 0x80;
|
unsigned char header = (unsigned char) (len - 129);
|
||||||
fwrite(&header, 1, 1, f);
|
fwrite(&header, 1, 1, f);
|
||||||
write_pixel(f, -1, comp, has_alpha, 0, first);
|
write_pixel(f, -1, comp, has_alpha, 0, begin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user