• 大小: 15KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-12
  • 语言: C/C++
  • 标签: 画图  gif  bmp  

资源简介

1. vs2008里弄了一个画数学函数的类,基本的函数都可以画,当然复杂的也可以,只是函数本身需要调用者设计,已经变量的范围 2. 最后的图象提供两种方式输出,一个是bmp文件,一个是gif图象,gif需要注意它的256种颜色限制 3. 不需要特别的库,里面的源代码应该能比较容易编译过,可能会在对应的blog里贴一些介绍 4. 我认为用这种代码可以很灵活的制作一些很绚丽的gif图片 5. 希望你们喜欢,或者给我提些改进的建议

资源截图

代码片段和文件信息



#include “baseLibrary.h“


/* LZW 编码和解码部分 */

class AsistantCompress
{
private:
int KS_LZW_CLEAN;
int KS_LZW_EOF;
int KS_LZW_MINCODE;
int KS_LZW_MAXBITLEN;
int KS_LZW_TABLESIZE;
int KS_LZW_HASHLEN;
int KS_LZW_HASHPRIME;

typedef struct _StringTable
{
int code;
unsigned char * str;
int strLen;
_StringTable * next;
}StringTable * PStringTable;

    StringTable *saTable;
    PStringTable *saHeadList;
    unsigned char * saTmpSrc;

int saTmpSrcLen;
int bitCount;
public:
AsistantCompress(int bitCount)
{
this->bitCount = bitCount;
KS_LZW_CLEAN = (1 << bitCount);
if (bitCount == 1)
KS_LZW_CLEAN = 4;
KS_LZW_EOF = KS_LZW_CLEAN + 1;
KS_LZW_MINCODE = KS_LZW_CLEAN + 2;
KS_LZW_MAXBITLEN = 12;
KS_LZW_TABLESIZE = (1 << KS_LZW_MAXBITLEN) - KS_LZW_MINCODE;
saTable = new StringTable[KS_LZW_TABLESIZE + 1];
KS_LZW_HASHLEN = 1024;
KS_LZW_HASHPRIME = 983;
saHeadList = new PStringTable[KS_LZW_HASHLEN];
saTmpSrcLen = 1920*1088;
        saTmpSrc = new unsigned char[saTmpSrcLen * 8 / bitCount];;
}
~AsistantCompress()
{
        KS_SAFE_DELETES(saTable);
        KS_SAFE_DELETES(saHeadList);
        KS_SAFE_DELETES(saTmpSrc);
}

int ks_lzw_compress(const unsigned char * src unsigned char * dst int srcLen)
{
if (saTmpSrcLen < srcLen)
{
saTmpSrcLen = srcLen;
            KS_SAFE_DELETES(saTmpSrc);
saTmpSrc = new unsigned char[srcLen * 8 / bitCount];
}
for (int i = 0; i < srcLen; i++)
for (int j = 0; j < 8 / bitCount; j++)
saTmpSrc[i * 8 / bitCount + j] = (src[i] >> j * bitCount) & ((1 << bitCount) - 1);

memset(saTable 0 (KS_LZW_TABLESIZE + 1) * sizeof(StringTable));
int tableLen = 0;
memset(saHeadList 0 KS_LZW_HASHLEN * sizeof(PStringTable));

int dstLen = 0;
int curNotUseBit = 8;
int curBitLen = bitCount + 1;

if (bitCount == 1)
curBitLen = 3;

int curMaxCode = 1 << curBitLen;

dst[0] = 0;

int curCode = KS_LZW_MINCODE;

        unsigned char * pred = saTmpSrc;
int predLen = 0;

ks_lzw_compressWrite(KS_LZW_CLEAN dst dstLen curNotUseBit curBitLen);

for (int i = 0; i < srcLen * 8 / bitCount; i++)
{
predLen++;
if (ks_lzw_hashSearch(pred predLen) == -1)
{
int code = ks_lzw_hashSearch(pred predLen - 1);
ks_lzw_compressWrite(code dst dstLen curNotUseBit curBitLen);

PStringTable p = &saTable[tableLen++];
p->code = curCode;
p->str = pred;
p->strLen = predLen;
ks_lzw_hashInsert(p);

if ((curCode++) == curMaxCode)
{
if (curBitLen != KS_LZW_MAXBITLEN)
{
curMaxCode <<= 1;
curBitLen++;
}
else
{
ks_lzw_compressWrite(KS_LZW_CLEAN dst dstLen curNotUseBit curBitLen);
curBitLen = bitCount + 1;
if (bitCount == 1)
curBitLen = 3;
curMaxCode = 1 << curBitLen;
curCode = KS_LZW_MINCODE;
memset(saTable 0 (K

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-02-05 20:58  baseLibrary\
     文件       22119  2013-02-05 20:50  baseLibrary\baseLibrary.cpp
     文件        8125  2013-02-05 17:13  baseLibrary\baseLibrary.h
     文件        4112  2013-02-05 20:50  baseLibrary\baseLibray.vcproj
     文件        1401  2013-02-05 20:55  baseLibrary\baseLibray.vcproj.PC-201102151844.Administrator.user
     目录           0  2013-02-05 20:58  baseLibrary\Debug\
     目录           0  2013-02-05 20:58  baseLibrary\Release\
     文件         390  2013-01-31 10:01  baseLibrary\dllmain.cpp
     文件        1348  2013-02-05 20:50  baseLibrary.sln
     目录           0  2013-02-05 20:58  Debug\
     目录           0  2013-02-05 20:58  Release\
     目录           0  2013-02-05 20:58  Test\
     目录           0  2013-02-05 20:58  Test\Debug\
     目录           0  2013-02-05 20:58  Test\Release\
     文件        3999  2013-02-02 20:11  Test\Test.vcproj
     文件        1427  2013-02-05 20:55  Test\Test.vcproj.PC-201102151844.Administrator.user
     文件        6219  2013-02-05 20:53  Test\a.cpp

评论

共有 条评论