1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-23 06:38:05 +01:00

gif update from Graham Whitted <gbw@sgrail.com>

removed cycle_bench() from testgrad
This commit is contained in:
kojima
2000-02-29 18:10:27 +00:00
parent fea35bfc99
commit 34c4040d91
2 changed files with 21 additions and 18 deletions

View File

@@ -44,10 +44,10 @@ RImage*
RLoadGIF(RContext *context, char *file, int index) RLoadGIF(RContext *context, char *file, int index)
{ {
RImage *image = NULL; RImage *image = NULL;
#if 0 unsigned char *cptr;
GifFileType *gif = NULL; GifFileType *gif = NULL;
GifPixelType *buffer = NULL; GifPixelType *buffer = NULL;
int i, j, k, ofs = 0; int i, j, k;
int width, height; int width, height;
GifRecordType recType; GifRecordType recType;
ColorMapObject *colormap; ColorMapObject *colormap;
@@ -136,6 +136,12 @@ RLoadGIF(RContext *context, char *file, int index)
if (gif->Image.Interlace) { if (gif->Image.Interlace) {
int l; int l;
int pelsPerLine;
if (RRGBAFormat==image->format)
pelsPerLine = width * 4;
else
pelsPerLine = width * 3;
for (j = 0; j < 4; j++) { for (j = 0; j < 4; j++) {
for (k = InterlacedOffset[j]; k < height; for (k = InterlacedOffset[j]; k < height;
@@ -143,25 +149,28 @@ RLoadGIF(RContext *context, char *file, int index)
if (DGifGetLine(gif, buffer, width)==GIF_ERROR) { if (DGifGetLine(gif, buffer, width)==GIF_ERROR) {
goto giferr; goto giferr;
} }
ofs = k*width; cptr = image->data + (k*pelsPerLine);
for (l = 0; l < width; l++, ofs++) { for (l = 0; l < width; l++) {
int pixel = buffer[l]; int pixel = buffer[l];
image->data[0][ofs] = rmap[pixel]; *cptr++ = rmap[pixel];
image->data[1][ofs] = gmap[pixel]; *cptr++ = gmap[pixel];
image->data[2][ofs] = bmap[pixel]; *cptr++ = bmap[pixel];
} }
} }
} }
} else { } else {
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++, ofs++) { for (k = 0; k < width; k++) {
int pixel = buffer[k]; int pixel = buffer[k];
image->data[0][ofs] = rmap[pixel]; *cptr++ = rmap[pixel];
image->data[1][ofs] = gmap[pixel]; *cptr++ = gmap[pixel];
image->data[2][ofs] = bmap[pixel]; *cptr++ = bmap[pixel];
if (RRGBAFormat==image->format)
cptr++;
} }
} }
} }
@@ -209,7 +218,7 @@ did_not_get_any_errors:
if (gif) if (gif)
DGifCloseFile(gif); DGifCloseFile(gif);
#endif
return image; return image;
} }

View File

@@ -190,15 +190,9 @@ int main(int argc, char **argv)
printf("average time per convertion %f sec\n", rt/i); printf("average time per convertion %f sec\n", rt/i);
printf("------------------------------------------\n"); printf("------------------------------------------\n");
#else #else
cycle_bench(1);
imgh = RRenderMultiGradient(250, 250, colors, RGRD_HORIZONTAL); imgh = RRenderMultiGradient(250, 250, colors, RGRD_HORIZONTAL);
cycle_bench(0);
cycle_bench(1);
imgv = RRenderMultiGradient(250, 250, colors, RGRD_VERTICAL); imgv = RRenderMultiGradient(250, 250, colors, RGRD_VERTICAL);
cycle_bench(0);
cycle_bench(1);
imgd = RRenderMultiGradient(250, 250, colors, RGRD_DIAGONAL); imgd = RRenderMultiGradient(250, 250, colors, RGRD_DIAGONAL);
cycle_bench(0);
RConvertImage(ctx, imgh, &pix); RConvertImage(ctx, imgh, &pix);
XCopyArea(dpy, pix, win, ctx->copy_gc, 0, 0, 250, 250, 0, 0); XCopyArea(dpy, pix, win, ctx->copy_gc, 0, 0, 250, 250, 0, 0);