Commit fc7cb865 authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

Pixels.c: scope improvements

parent f8a1f79b
...@@ -63,10 +63,6 @@ int nxagentUniquePixels(XImage *image) ...@@ -63,10 +63,6 @@ int nxagentUniquePixels(XImage *image)
int elements = PIXEL_ELEMENTS; int elements = PIXEL_ELEMENTS;
int unique = 0; int unique = 0;
int total;
int ratio;
int step;
int last = -1; int last = -1;
const char *next = image -> data; const char *next = image -> data;
...@@ -80,9 +76,9 @@ int nxagentUniquePixels(XImage *image) ...@@ -80,9 +76,9 @@ int nxagentUniquePixels(XImage *image)
* Take at most 256 pixels from the image. * Take at most 256 pixels from the image.
*/ */
total = image -> width * image -> height; int total = image -> width * image -> height;
step = total / elements; int step = total / elements;
if (step < PIXEL_STEP) if (step < PIXEL_STEP)
{ {
...@@ -231,7 +227,7 @@ int nxagentUniquePixels(XImage *image) ...@@ -231,7 +227,7 @@ int nxagentUniquePixels(XImage *image)
#endif #endif
} }
ratio = unique * 100 / elements; int ratio = unique * 100 / elements;
#ifdef TEST #ifdef TEST
fprintf(stderr, "nxagentUniquePixels: Found [%d] unique pixels out of [%d] with ratio [%d%%].\n", fprintf(stderr, "nxagentUniquePixels: Found [%d] unique pixels out of [%d] with ratio [%d%%].\n",
...@@ -267,13 +263,11 @@ unsigned int Get16(const char *buffer, int order) ...@@ -267,13 +263,11 @@ unsigned int Get16(const char *buffer, int order)
unsigned int Get24(const char *buffer, int order) unsigned int Get24(const char *buffer, int order)
{ {
int i;
const char *next = (order == MSBFirst ? buffer : buffer + 2); const char *next = (order == MSBFirst ? buffer : buffer + 2);
unsigned int result = 0; unsigned int result = 0;
for (i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
result <<= 8; result <<= 8;
...@@ -294,13 +288,11 @@ unsigned int Get24(const char *buffer, int order) ...@@ -294,13 +288,11 @@ unsigned int Get24(const char *buffer, int order)
unsigned int Get32(const char *buffer, int order) unsigned int Get32(const char *buffer, int order)
{ {
int i;
const char *next = (order == MSBFirst ? buffer : buffer + 3); const char *next = (order == MSBFirst ? buffer : buffer + 3);
unsigned int result = 0; unsigned int result = 0;
for (i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
result <<= 8; result <<= 8;
...@@ -341,13 +333,11 @@ void Put16(unsigned int value, char *buffer, int order) ...@@ -341,13 +333,11 @@ void Put16(unsigned int value, char *buffer, int order)
void Put24(unsigned int value, char *buffer, int order) void Put24(unsigned int value, char *buffer, int order)
{ {
int i;
if (order == MSBFirst) if (order == MSBFirst)
{ {
buffer += 2; buffer += 2;
for (i = 3; i > 0; i--) for (int i = 3; i > 0; i--)
{ {
*buffer-- = (unsigned char) (value & 0xff); *buffer-- = (unsigned char) (value & 0xff);
...@@ -356,7 +346,7 @@ void Put24(unsigned int value, char *buffer, int order) ...@@ -356,7 +346,7 @@ void Put24(unsigned int value, char *buffer, int order)
} }
else else
{ {
for (i = 3; i > 0; i--) for (int i = 3; i > 0; i--)
{ {
*buffer++ = (unsigned char) (value & 0xff); *buffer++ = (unsigned char) (value & 0xff);
...@@ -367,13 +357,11 @@ void Put24(unsigned int value, char *buffer, int order) ...@@ -367,13 +357,11 @@ void Put24(unsigned int value, char *buffer, int order)
void Put32(unsigned int value, char *buffer, int order) void Put32(unsigned int value, char *buffer, int order)
{ {
int i;
if (order == MSBFirst) if (order == MSBFirst)
{ {
buffer += 3; buffer += 3;
for (i = 4; i > 0; i--) for (int i = 4; i > 0; i--)
{ {
*buffer-- = (unsigned char) (value & 0xff); *buffer-- = (unsigned char) (value & 0xff);
...@@ -382,7 +370,7 @@ void Put32(unsigned int value, char *buffer, int order) ...@@ -382,7 +370,7 @@ void Put32(unsigned int value, char *buffer, int order)
} }
else else
{ {
for (i = 4; i > 0; i--) for (int i = 4; i > 0; i--)
{ {
*buffer++ = (unsigned char) (value & 0xff); *buffer++ = (unsigned char) (value & 0xff);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment