亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? quantize.c

?? SigmDesign SMP8634 media decode chip development SDK
?? C
字號:
/***************************************************************************** *   "Gif-Lib" - Yet another gif library. * * Written by:  Gershon Elber            IBM PC Ver 0.1,    Jun. 1989 ****************************************************************************** * Module to quatize high resolution image into lower one. You may want to * peek into the following article this code is based on: * "Color Image Quantization for frame buffer Display", by Paul Heckbert * SIGGRAPH 1982 page 297-307. ****************************************************************************** * History: * 5 Jan 90 - Version 1.0 by Gershon Elber. *****************************************************************************/#ifdef HAVE_CONFIG_H#include <config.h>#endif#ifdef __MSDOS__#include <dos.h>#include <alloc.h>#include <graphics.h>#endif /* __MSDOS__ */#include <stdlib.h>#include <stdio.h>#include "gif_lib.h"#include "gif_lib_private.h"#define ABS(x)    ((x) > 0 ? (x) : (-(x)))/* The colors are stripped to 5 bits per primary color if non MSDOS system * or to 4 (not enough memory...) if MSDOS as first step. */#ifdef __MSDOS__#define COLOR_ARRAY_SIZE 4096#define BITS_PER_PRIM_COLOR 4#define MAX_PRIM_COLOR      0x0f#else#define COLOR_ARRAY_SIZE 32768#define BITS_PER_PRIM_COLOR 5#define MAX_PRIM_COLOR      0x1f#endif /* __MSDOS__ */static int SortRGBAxis;typedef struct QuantizedColorType {    GifByteType RGB[3];    GifByteType NewColorIndex;    long Count;    struct QuantizedColorType *Pnext;} QuantizedColorType;typedef struct NewColorMapType {    GifByteType RGBMin[3], RGBWidth[3];    unsigned int NumEntries; /* # of QuantizedColorType in linked list below */    unsigned long Count; /* Total number of pixels in all the entries */    QuantizedColorType *QuantizedColors;} NewColorMapType;static int SubdivColorMap(NewColorMapType * NewColorSubdiv,                          unsigned int ColorMapSize,                          unsigned int *NewColorMapSize);static int SortCmpRtn(const VoidPtr Entry1, const VoidPtr Entry2);/****************************************************************************** * Quantize high resolution image into lower one. Input image consists of a * 2D array for each of the RGB colors with size Width by Height. There is no * Color map for the input. Output is a quantized image with 2D array of * indexes into the output color map. *   Note input image can be 24 bits at the most (8 for red/green/blue) and * the output has 256 colors at the most (256 entries in the color map.). * ColorMapSize specifies size of color map up to 256 and will be updated to * real size before returning. *   Also non of the parameter are allocated by this routine. *   This function returns GIF_OK if succesfull, GIF_ERROR otherwise. ******************************************************************************/intQuantizeBuffer(unsigned int Width,               unsigned int Height,               int *ColorMapSize,               GifByteType * RedInput,               GifByteType * GreenInput,               GifByteType * BlueInput,               GifByteType * OutputBuffer,               GifColorType * OutputColorMap) {    unsigned int Index, NumOfEntries;    int i, j, MaxRGBError[3];    unsigned int NewColorMapSize;    long Red, Green, Blue;    NewColorMapType NewColorSubdiv[256];    QuantizedColorType *ColorArrayEntries, *QuantizedColor;    ColorArrayEntries = (QuantizedColorType *)malloc(                           sizeof(QuantizedColorType) * COLOR_ARRAY_SIZE);    if (ColorArrayEntries == NULL) {        _GifError = E_GIF_ERR_NOT_ENOUGH_MEM;        return GIF_ERROR;    }    for (i = 0; i < COLOR_ARRAY_SIZE; i++) {        ColorArrayEntries[i].RGB[0] = i >> (2 * BITS_PER_PRIM_COLOR);        ColorArrayEntries[i].RGB[1] = (i >> BITS_PER_PRIM_COLOR) &           MAX_PRIM_COLOR;        ColorArrayEntries[i].RGB[2] = i & MAX_PRIM_COLOR;        ColorArrayEntries[i].Count = 0;    }    /* Sample the colors and their distribution: */    for (i = 0; i < (int)(Width * Height); i++) {        Index = ((RedInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<                  (2 * BITS_PER_PRIM_COLOR)) +                ((GreenInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<                  BITS_PER_PRIM_COLOR) +                (BlueInput[i] >> (8 - BITS_PER_PRIM_COLOR));        ColorArrayEntries[Index].Count++;    }    /* Put all the colors in the first entry of the color map, and call the     * recursive subdivision process.  */    for (i = 0; i < 256; i++) {        NewColorSubdiv[i].QuantizedColors = NULL;        NewColorSubdiv[i].Count = NewColorSubdiv[i].NumEntries = 0;        for (j = 0; j < 3; j++) {            NewColorSubdiv[i].RGBMin[j] = 0;            NewColorSubdiv[i].RGBWidth[j] = 255;        }    }    /* Find the non empty entries in the color table and chain them: */    for (i = 0; i < COLOR_ARRAY_SIZE; i++)        if (ColorArrayEntries[i].Count > 0)            break;    QuantizedColor = NewColorSubdiv[0].QuantizedColors = &ColorArrayEntries[i];    NumOfEntries = 1;    while (++i < COLOR_ARRAY_SIZE)        if (ColorArrayEntries[i].Count > 0) {            QuantizedColor->Pnext = &ColorArrayEntries[i];            QuantizedColor = &ColorArrayEntries[i];            NumOfEntries++;        }    QuantizedColor->Pnext = NULL;    NewColorSubdiv[0].NumEntries = NumOfEntries; /* Different sampled colors */    NewColorSubdiv[0].Count = ((long)Width) * Height; /* Pixels */    NewColorMapSize = 1;    if (SubdivColorMap(NewColorSubdiv, *ColorMapSize, &NewColorMapSize) !=       GIF_OK) {        free((char *)ColorArrayEntries);        return GIF_ERROR;    }    if (NewColorMapSize < *ColorMapSize) {        /* And clear rest of color map: */        for (i = NewColorMapSize; i < *ColorMapSize; i++)            OutputColorMap[i].Red = OutputColorMap[i].Green =                OutputColorMap[i].Blue = 0;    }    /* Average the colors in each entry to be the color to be used in the     * output color map, and plug it into the output color map itself. */    for (i = 0; i < NewColorMapSize; i++) {        if ((j = NewColorSubdiv[i].NumEntries) > 0) {            QuantizedColor = NewColorSubdiv[i].QuantizedColors;            Red = Green = Blue = 0;            while (QuantizedColor) {                QuantizedColor->NewColorIndex = i;                Red += QuantizedColor->RGB[0];                Green += QuantizedColor->RGB[1];                Blue += QuantizedColor->RGB[2];                QuantizedColor = QuantizedColor->Pnext;            }            OutputColorMap[i].Red = (Red << (8 - BITS_PER_PRIM_COLOR)) / j;            OutputColorMap[i].Green = (Green << (8 - BITS_PER_PRIM_COLOR)) / j;            OutputColorMap[i].Blue = (Blue << (8 - BITS_PER_PRIM_COLOR)) / j;        } else            fprintf(stderr,                    "\n%s: Null entry in quantized color map - that's weird.\n",                    PROGRAM_NAME);    }    /* Finally scan the input buffer again and put the mapped index in the     * output buffer.  */    MaxRGBError[0] = MaxRGBError[1] = MaxRGBError[2] = 0;    for (i = 0; i < (int)(Width * Height); i++) {        Index = ((RedInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<                 (2 * BITS_PER_PRIM_COLOR)) +                ((GreenInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<                 BITS_PER_PRIM_COLOR) +                (BlueInput[i] >> (8 - BITS_PER_PRIM_COLOR));        Index = ColorArrayEntries[Index].NewColorIndex;        OutputBuffer[i] = Index;        if (MaxRGBError[0] < ABS(OutputColorMap[Index].Red - RedInput[i]))            MaxRGBError[0] = ABS(OutputColorMap[Index].Red - RedInput[i]);        if (MaxRGBError[1] < ABS(OutputColorMap[Index].Green - GreenInput[i]))            MaxRGBError[1] = ABS(OutputColorMap[Index].Green - GreenInput[i]);        if (MaxRGBError[2] < ABS(OutputColorMap[Index].Blue - BlueInput[i]))            MaxRGBError[2] = ABS(OutputColorMap[Index].Blue - BlueInput[i]);    }#ifdef DEBUG    fprintf(stderr,            "Quantization L(0) errors: Red = %d, Green = %d, Blue = %d.\n",            MaxRGBError[0], MaxRGBError[1], MaxRGBError[2]);#endif /* DEBUG */    free((char *)ColorArrayEntries);    *ColorMapSize = NewColorMapSize;    return GIF_OK;}/****************************************************************************** * Routine to subdivide the RGB space recursively using median cut in each * axes alternatingly until ColorMapSize different cubes exists. * The biggest cube in one dimension is subdivide unless it has only one entry. * Returns GIF_ERROR if failed, otherwise GIF_OK. ******************************************************************************/static intSubdivColorMap(NewColorMapType * NewColorSubdiv,               unsigned int ColorMapSize,               unsigned int *NewColorMapSize) {    int MaxSize;    unsigned int i, j, Index = 0, NumEntries, MinColor, MaxColor;    long Sum, Count;    QuantizedColorType *QuantizedColor, **SortArray;    while (ColorMapSize > *NewColorMapSize) {        /* Find candidate for subdivision: */        MaxSize = -1;        for (i = 0; i < *NewColorMapSize; i++) {            for (j = 0; j < 3; j++) {                if ((((int)NewColorSubdiv[i].RGBWidth[j]) > MaxSize) &&                      (NewColorSubdiv[i].NumEntries > 1)) {                    MaxSize = NewColorSubdiv[i].RGBWidth[j];                    Index = i;                    SortRGBAxis = j;                }            }        }        if (MaxSize == -1)            return GIF_OK;        /* Split the entry Index into two along the axis SortRGBAxis: */        /* Sort all elements in that entry along the given axis and split at         * the median.  */        SortArray = (QuantizedColorType **)malloc(                      sizeof(QuantizedColorType *) *                       NewColorSubdiv[Index].NumEntries);        if (SortArray == NULL)            return GIF_ERROR;        for (j = 0, QuantizedColor = NewColorSubdiv[Index].QuantizedColors;             j < NewColorSubdiv[Index].NumEntries && QuantizedColor != NULL;             j++, QuantizedColor = QuantizedColor->Pnext)            SortArray[j] = QuantizedColor;        qsort(SortArray, NewColorSubdiv[Index].NumEntries,              sizeof(QuantizedColorType *), SortCmpRtn);        /* Relink the sorted list into one: */        for (j = 0; j < NewColorSubdiv[Index].NumEntries - 1; j++)            SortArray[j]->Pnext = SortArray[j + 1];        SortArray[NewColorSubdiv[Index].NumEntries - 1]->Pnext = NULL;        NewColorSubdiv[Index].QuantizedColors = QuantizedColor = SortArray[0];        free((char *)SortArray);        /* Now simply add the Counts until we have half of the Count: */        Sum = NewColorSubdiv[Index].Count / 2 - QuantizedColor->Count;        NumEntries = 1;        Count = QuantizedColor->Count;        while ((Sum -= QuantizedColor->Pnext->Count) >= 0 &&               QuantizedColor->Pnext != NULL &&               QuantizedColor->Pnext->Pnext != NULL) {            QuantizedColor = QuantizedColor->Pnext;            NumEntries++;            Count += QuantizedColor->Count;        }        /* Save the values of the last color of the first half, and first         * of the second half so we can update the Bounding Boxes later.         * Also as the colors are quantized and the BBoxes are full 0..255,         * they need to be rescaled.         */        MaxColor = QuantizedColor->RGB[SortRGBAxis]; /* Max. of first half */        MinColor = QuantizedColor->Pnext->RGB[SortRGBAxis]; /* of second */        MaxColor <<= (8 - BITS_PER_PRIM_COLOR);        MinColor <<= (8 - BITS_PER_PRIM_COLOR);        /* Partition right here: */        NewColorSubdiv[*NewColorMapSize].QuantizedColors =           QuantizedColor->Pnext;        QuantizedColor->Pnext = NULL;        NewColorSubdiv[*NewColorMapSize].Count = Count;        NewColorSubdiv[Index].Count -= Count;        NewColorSubdiv[*NewColorMapSize].NumEntries =           NewColorSubdiv[Index].NumEntries - NumEntries;        NewColorSubdiv[Index].NumEntries = NumEntries;        for (j = 0; j < 3; j++) {            NewColorSubdiv[*NewColorMapSize].RGBMin[j] =               NewColorSubdiv[Index].RGBMin[j];            NewColorSubdiv[*NewColorMapSize].RGBWidth[j] =               NewColorSubdiv[Index].RGBWidth[j];        }        NewColorSubdiv[*NewColorMapSize].RGBWidth[SortRGBAxis] =           NewColorSubdiv[*NewColorMapSize].RGBMin[SortRGBAxis] +           NewColorSubdiv[*NewColorMapSize].RGBWidth[SortRGBAxis] - MinColor;        NewColorSubdiv[*NewColorMapSize].RGBMin[SortRGBAxis] = MinColor;        NewColorSubdiv[Index].RGBWidth[SortRGBAxis] =           MaxColor - NewColorSubdiv[Index].RGBMin[SortRGBAxis];        (*NewColorMapSize)++;    }    return GIF_OK;}/**************************************************************************** * Routine called by qsort to compare to entries. ****************************************************************************/static intSortCmpRtn(const VoidPtr Entry1,           const VoidPtr Entry2) {    return (*((QuantizedColorType **) Entry1))->RGB[SortRGBAxis] -       (*((QuantizedColorType **) Entry2))->RGB[SortRGBAxis];}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久亚洲私人国产精品va媚药| 久久综合久久鬼色中文字| 欧美日本一区二区三区四区| 日韩午夜av电影| 精品在线一区二区| 久久亚洲春色中文字幕久久久| 成人精品高清在线| 亚洲综合一区二区三区| 91精品国产高清一区二区三区| 青青草成人在线观看| 精品国产乱码久久久久久老虎| 蜜臀av性久久久久蜜臀aⅴ流畅| 在线不卡a资源高清| 国产精品18久久久久久久久| 日本伊人色综合网| 亚洲成av人综合在线观看| 国产一区日韩二区欧美三区| 一本色道久久加勒比精品| 国产亚洲成年网址在线观看| 日韩高清不卡一区二区三区| 在线观看日韩毛片| 亚洲视频每日更新| 99精品桃花视频在线观看| 欧美经典一区二区三区| 国产在线国偷精品产拍免费yy| 欧美精品成人一区二区三区四区| 亚洲精品国产一区二区精华液| av不卡免费电影| 亚洲婷婷在线视频| 91亚洲男人天堂| 国产精品理论片在线观看| 高清在线不卡av| 欧美激情艳妇裸体舞| 成人午夜在线播放| **网站欧美大片在线观看| 99亚偷拍自图区亚洲| 中文字幕色av一区二区三区| 成人app网站| 一区二区在线观看免费| 在线国产电影不卡| 日韩精品一区第一页| 91精品国产91热久久久做人人 | 亚洲色图19p| 91蜜桃网址入口| 亚洲精品成人悠悠色影视| 色天天综合色天天久久| 亚洲美女淫视频| 欧美天天综合网| 日产欧产美韩系列久久99| 日韩av不卡在线观看| 精品一区二区三区av| 欧美影视一区在线| 欧美三级电影在线观看| 欧美日韩日本视频| 国产欧美日韩在线观看| 亚洲精品视频自拍| 精东粉嫩av免费一区二区三区 | 亚洲精品一区二区三区99| 国产精品久久久久aaaa樱花| 一区二区三区在线看| 91麻豆免费看片| 日韩福利电影在线| 久久久亚洲精品一区二区三区 | 亚洲男人天堂一区| 欧美久久久一区| 国产精品66部| 亚洲一区影音先锋| 久久久久亚洲综合| 在线观看精品一区| 国产精品一卡二卡| 亚洲午夜视频在线| 国产欧美一区二区精品忘忧草| 色婷婷av一区| 国产激情91久久精品导航 | 欧美国产综合一区二区| 欧美日韩亚洲不卡| 成人做爰69片免费看网站| 视频一区二区中文字幕| 国产精品色婷婷| 日韩一区二区麻豆国产| 国产真实乱偷精品视频免| 亚洲高清视频在线| 亚洲欧洲日韩女同| 精品国产91乱码一区二区三区 | 成人免费毛片a| 秋霞午夜鲁丝一区二区老狼| 中文字幕在线免费不卡| 欧美mv日韩mv| 91精品国产福利在线观看| 91麻豆精品视频| 大胆欧美人体老妇| 亚洲一区在线观看视频| 色婷婷综合激情| 久久99国产精品成人| 偷窥国产亚洲免费视频| 欧美日韩一级大片网址| 男男视频亚洲欧美| 国产精品色眯眯| 欧美日韩你懂得| 精品一区二区国语对白| 国产精品视频第一区| 99久久99久久免费精品蜜臀| 亚洲欧美日韩一区| 久久中文字幕电影| 欧美视频精品在线观看| 成人一级片网址| 国产91精品一区二区麻豆网站| 男人操女人的视频在线观看欧美| 亚洲国产cao| 亚洲国产一区二区三区青草影视| 亚洲欧洲av在线| 成人免费一区二区三区视频| 国产日韩欧美高清在线| 久久久久高清精品| 国产天堂亚洲国产碰碰| 久久综合久久鬼色中文字| 久久久久久久久久电影| 久久久久99精品国产片| www一区二区| 国产偷国产偷精品高清尤物 | 成人教育av在线| 国产精品夜夜爽| 成人激情小说乱人伦| 91玉足脚交白嫩脚丫在线播放| 亚洲美女在线国产| 亚洲视频一区在线观看| 亚洲丝袜另类动漫二区| 欧美一级专区免费大片| 日韩欧美国产一区二区在线播放 | 视频一区国产视频| 蜜乳av一区二区| 国产成人av福利| 91在线国产观看| 欧美日韩国产综合草草| 91精品国产aⅴ一区二区| 2欧美一区二区三区在线观看视频 337p粉嫩大胆噜噜噜噜噜91av | 成人av免费在线播放| 精品一区二区久久| 成人免费毛片a| 国模套图日韩精品一区二区| 亚洲国产另类av| 亚洲人成在线观看一区二区| 国产亚洲欧美日韩日本| 国产精品麻豆欧美日韩ww| 亚洲视频每日更新| 国产成人亚洲综合a∨婷婷| 欧美亚洲禁片免费| 91麻豆精品国产91久久久资源速度 | 日韩在线卡一卡二| 国产尤物一区二区| 色综合天天在线| 欧美理论在线播放| 精品不卡在线视频| 成人欧美一区二区三区黑人麻豆| 亚洲成人动漫一区| 国产成人久久精品77777最新版本| 99re热视频这里只精品| 3751色影院一区二区三区| 26uuu精品一区二区三区四区在线| 国产欧美精品国产国产专区| 亚洲一区av在线| 国产一区二区女| 91啪亚洲精品| 久久综合999| 日韩专区一卡二卡| av电影一区二区| 久久综合av免费| 日韩avvvv在线播放| 色悠悠亚洲一区二区| 337p日本欧洲亚洲大胆精品| 亚洲成人精品影院| 91麻豆国产精品久久| 久久奇米777| 三级成人在线视频| 91极品视觉盛宴| 国产精品毛片久久久久久| 日韩在线观看一区二区| 欧美在线高清视频| 亚洲精品视频在线观看网站| 国产精品99久久久久久似苏梦涵| 欧美日本一区二区| 亚洲一区二区三区在线看| av在线不卡网| 国产精品看片你懂得| 国产美女一区二区| 夜夜亚洲天天久久| 国产美女久久久久| 在线亚洲欧美专区二区| 亚洲欧洲av在线| 成人高清av在线| 国产精品久久久久久久久晋中| 国产久卡久卡久卡久卡视频精品| 91精品久久久久久久91蜜桃| 亚洲国产综合人成综合网站| 日本精品一级二级| 亚洲一区二区av在线| 欧美亚洲动漫制服丝袜| 亚洲自拍偷拍av| 欧美日本高清视频在线观看| 亚洲成人免费av|