1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-02-24 11:15:51 +01:00

gif.c code style

This patch removes some extra curly brackets, some empty lines,
extra spaces,...

This patch is not removing the goto calls. I am not sure if the code
is better without gotos.
This commit is contained in:
Rodolfo García Peñas (kix)
2013-09-05 21:08:13 +02:00
committed by Carlos R. Mafra
parent 2bdeb693f6
commit f363292d3c

View File

@@ -49,9 +49,7 @@ RImage *RLoadGIF(const char *file, int index)
int width, height; int width, height;
GifRecordType recType; GifRecordType recType;
ColorMapObject *colormap; ColorMapObject *colormap;
unsigned char rmap[256]; unsigned char rmap[256], gmap[256], bmap[256];
unsigned char gmap[256];
unsigned char bmap[256];
if (index < 0) if (index < 0)
index = 0; index = 0;
@@ -83,24 +81,22 @@ RImage *RLoadGIF(const char *file, int index)
} }
colormap = gif->SColorMap; colormap = gif->SColorMap;
i = 0; i = 0;
do { do {
int extCode; int extCode;
GifByteType *extension; GifByteType *extension;
if (DGifGetRecordType(gif, &recType) == GIF_ERROR) { if (DGifGetRecordType(gif, &recType) == GIF_ERROR)
goto giferr; goto giferr;
}
switch (recType) { switch (recType) {
case IMAGE_DESC_RECORD_TYPE: case IMAGE_DESC_RECORD_TYPE:
if (i++ != index) if (i++ != index)
break; break;
if (DGifGetImageDesc(gif) == GIF_ERROR) { if (DGifGetImageDesc(gif) == GIF_ERROR)
goto giferr; goto giferr;
}
width = gif->Image.Width; width = gif->Image.Width;
height = gif->Image.Height; height = gif->Image.Height;
@@ -109,17 +105,9 @@ RImage *RLoadGIF(const char *file, int index)
colormap = gif->Image.ColorMap; colormap = gif->Image.ColorMap;
/* the gif specs talk about a default colormap, but it /* the gif specs talk about a default colormap, but it
* doesnt say what the heck is this default colormap */ * doesnt say what the heck is this default colormap
if (!colormap) { * Render anything */
/* if (colormap) {
* Well, since the spec says the colormap can be anything,
* lets just render it with whatever garbage the stack
* has :)
*
goto bye;
*/
} else {
for (j = 0; j < colormap->ColorCount; j++) { for (j = 0; j < colormap->ColorCount; j++) {
rmap[j] = colormap->Colors[j].Red; rmap[j] = colormap->Colors[j].Red;
gmap[j] = colormap->Colors[j].Green; gmap[j] = colormap->Colors[j].Green;
@@ -134,13 +122,11 @@ RImage *RLoadGIF(const char *file, int index)
} }
image = RCreateImage(width, height, False); image = RCreateImage(width, height, False);
if (!image) { if (!image)
goto bye; goto bye;
}
if (gif->Image.Interlace) { if (gif->Image.Interlace) {
int l; int l, pelsPerLine;
int pelsPerLine;
if (RRGBAFormat == image->format) if (RRGBAFormat == image->format)
pelsPerLine = width * 4; pelsPerLine = width * 4;
@@ -149,9 +135,9 @@ RImage *RLoadGIF(const char *file, int index)
for (j = 0; j < 4; j++) { for (j = 0; j < 4; j++) {
for (k = InterlacedOffset[j]; k < height; k += InterlacedJumps[j]) { for (k = InterlacedOffset[j]; k < height; k += InterlacedJumps[j]) {
if (DGifGetLine(gif, buffer, width) == GIF_ERROR) { if (DGifGetLine(gif, buffer, width) == GIF_ERROR)
goto giferr; goto giferr;
}
cptr = image->data + (k * pelsPerLine); cptr = image->data + (k * pelsPerLine);
for (l = 0; l < width; l++) { for (l = 0; l < width; l++) {
int pixel = buffer[l]; int pixel = buffer[l];
@@ -164,9 +150,9 @@ RImage *RLoadGIF(const char *file, int index)
} else { } else {
cptr = image->data; cptr = image->data;
for (j = 0; j < height; j++) { for (j = 0; j < height; j++) {
if (DGifGetLine(gif, buffer, width) == GIF_ERROR) { if (DGifGetLine(gif, buffer, width) == GIF_ERROR)
goto giferr; goto giferr;
}
for (k = 0; k < width; k++) { for (k = 0; k < width; k++) {
int pixel = buffer[k]; int pixel = buffer[k];
*cptr++ = rmap[pixel]; *cptr++ = rmap[pixel];
@@ -181,14 +167,13 @@ RImage *RLoadGIF(const char *file, int index)
case EXTENSION_RECORD_TYPE: case EXTENSION_RECORD_TYPE:
/* skip all extension blocks */ /* skip all extension blocks */
if (DGifGetExtension(gif, &extCode, &extension) == GIF_ERROR) { if (DGifGetExtension(gif, &extCode, &extension) == GIF_ERROR)
goto giferr; goto giferr;
}
while (extension) { while (extension)
if (DGifGetExtensionNext(gif, &extension) == GIF_ERROR) { if (DGifGetExtensionNext(gif, &extension) == GIF_ERROR)
goto giferr; goto giferr;
}
}
break; break;
default: default: