Bmp2Gif 的源碼,who要!

bzshow 2000-12-15 01:43:00
Bmp2Gif 的源碼,who要!
寫下你的email
...全文
317 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
michaelh 2001-04-25
  • 打赏
  • 举报
回复
please give me a copy: my address: michael_huyl@21cn.com
yhl1978 2001-03-03
  • 打赏
  • 举报
回复
bzshow老兄:
小弟这厢有礼,因需要急需你的转换算法,一定十分感谢!
martin_yhl@sohu.com
非常感谢!
bzshow 2000-12-29
  • 打赏
  • 举报
回复
如果真要, email me:

b-_-z@21cn.com
lenity 2000-12-27
  • 打赏
  • 举报
回复
老兄,也给我份Bmp2Gif的源码吧,lenity_cn@263.net
fy 2000-12-26
  • 打赏
  • 举报
回复
yzfangyong@elong.com
谢谢:)
myb123 2000-12-26
  • 打赏
  • 举报
回复
mowencong@21cn.com
谢谢:)
viv_wangsc 2000-12-22
  • 打赏
  • 举报
回复
viv_wangsc@163.net
谢谢:)
bzshow 2000-12-19
  • 打赏
  • 举报
回复
/* bmp2gif.c -- See end-of-file for (C) */
/* This was written for Microsoft 32-bit-integer compilers--it
* should compile with
* cl gif2bmp.c
* to produce the executable gif2bmp.exe
*
* The Microsoft oddities are:
* The funny include files -- they may be omitted on compilers
* that can not find them (stdio.h better be there, however)
* #pragma pack(1) -- This forces the BITMAPFILEHEADER structure
* to be the same length in memory as in files (otherwise, the structure
* is padded out to be a multiple of 8? bytes long
* Note that Microsoft uses all-caps for typedefs. Ugh.
*/
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>

typedef unsigned char byte;
typedef unsigned short WORD;
typedef unsigned long DWORD;

#pragma pack(1)
typedef struct tagRGBQUAD {
byte rgbBlue;
byte rgbGreen;
byte rgbRed;
byte rgbReserved;
} RGBQUAD;
typedef struct tagBITMAPFILEHEADER {
WORD bfType;
DWORD bfSize;
WORD bfReserved1;
WORD bfReserved2;
DWORD bfOffBits;
} BITMAPFILEHEADER;
typedef BITMAPFILEHEADER *PBITMAPFILEHEADER;

typedef struct tagBITMAPINFOHEADER{
DWORD biSize;
DWORD biWidth;
DWORD biHeight;
WORD biPlanes;
WORD biBitCount;

DWORD biCompression;
DWORD biSizeImage;
DWORD biXPelsPerMeter;
DWORD biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
} BITMAPINFOHEADER;

BITMAPFILEHEADER hdr;
BITMAPINFOHEADER bi;
long wib;
int yat;
unsigned char cmap[256*4]; /* Bytes of blue, green, red, reserved */
unsigned char omap[256*4]; /* Output colormap */
unsigned char *scanline;
unsigned char used[256];

FILE *fpin; /* Input file fp */
int c666= 0; /* Force output colormap to 666 colors */
int ncolors;

int fread_chk(char *cp, int n, int count, FILE *fp){
int c= fread(cp, n, count, fp);
if(c!=count){
perror("Read error:");
exit(1);
}
}
int fwrite_chk(char *cp, int n, int count, FILE *fp){
int c= fwrite(cp, n, count, fp);
if(c!=count){
perror("Write error:");
exit(1);
}
}
static int dib_wib(int bitcount, int wi){
switch (bitcount){
case 1: wi= (wi+31) >> 3; break;
case 4: wi= (wi+7) >> 1; break;
case 8: wi= wi+3; break;
case 24:wi= (wi*3)+3; break;
}
return wi & ~3;
}
void err(char *msg){
fprintf(stderr, "%s\n", msg);
exit(5);
}
void gulp(char *dibname){
int nbytes;
int v, y;

if((fpin= fopen (dibname, "rb"))==0){
perror(dibname);
exit(0);
}
fread_chk((char *)(&hdr),1,sizeof(hdr),fpin);
if(hdr.bfType!= 0x4d42)
err("Image not a .bmp");

fread_chk((char *)(&bi), 1, sizeof(bi), fpin);

wib= dib_wib((int)bi.biBitCount, (int)bi.biWidth);
bi.biSizeImage= bi.biHeight * wib;
if(bi.biBitCount != 8)
err("Only 8-bit .bmp images are permitted");
if(bi.biBitCount<=8){
v= (int)((hdr.bfOffBits - bi.biSize - sizeof(BITMAPFILEHEADER))/sizeof(RGBQUAD));
bi.biClrUsed= v;
if(v>0)
fread_chk(cmap, sizeof(RGBQUAD), v, fpin);
if(c666){
int k= 4*v;
while(--k>=0)
cmap[k]= 51*((cmap[k]+25)/51);
}
}
scanline= malloc((int)wib);
if(scanline==0)
err("Not enough room for the scanline");
fread_chk(scanline, 1, (int)wib, fpin);
yat= 0;
}
static int GetPixel(int x, int y){
y= (int)(bi.biHeight-1-y); /* bmp files are upside-down */
if(y!=yat){
if(y!=yat+1)
if(0!=fseek(fpin, (y-(yat+1))*wib, SEEK_CUR)){
perror("Seek on input file");
exit(1);
}
fread_chk(scanline, 1, (int)wib, fpin);
yat= y;
}
return used[scanline[x]];
}
int formoutputcmap(){
int ncolors= 0;
int x, y;
for(x= 0; x<256; x++)used[x]= 0;
for(y= 0; y<(int)bi.biHeight; y++){
if(y!=0)
fread_chk(scanline, 1, (int)wib, fpin);
for(x= 0; x<(int)bi.biWidth; x++)
used[scanline[x]]= 1;
}
/* Count the number of colors used */
for(x= 0; x<256; x++)ncolors += used[x];
if(ncolors<2)
ncolors= 2;
for(x= y= 0; x<256; x++)if(used[x]!=0){
used[x]= y/3;
omap[y++]= cmap[4*x+2];
omap[y++]= cmap[4*x+1];
omap[y++]= cmap[4*x];
}
fclose(fpin);
return ncolors;
}
int nearestcolor(int *rgb){
int k;
int pv= 0;
int n= 1 << ((int)bi.biBitCount);
long del[3], len, minlen= 3*256L*256L;
unsigned char *cp= cmap;

for(k= 0; k<n; k++, cp+= 4){
del[0]= cp[0]-rgb[2];
del[1]= cp[1]-rgb[1];
del[2]= cp[2]-rgb[0];
len= del[0]*del[0] + del[1]*del[1] + del[2]*del[2];
if(len<minlen){
minlen= len;
pv= k;
}
}
return pv;
}
char *note[]= {
"Usage: [-i] [-x # [# #]] [-b # [# #]] source.bmp dest.gif",
"Create a .gif file from a Windows .bmp file",
"Options:",
"-i Interlace [default not]",
"-x # Set pvalue # transparent (# # # for transparent rgb)",
"-b # Set pvalue # background [default 0]",
// "-p # Bits per pixel (override the number in the .bmp file)",
"-c X Add comment X (use quoted string argument)",
"-n Convert colors to nearest Netscape color [multiple of 51]",
0};
char *comment;
typedef int (* ifunptr)(int, int);
static void GIFEncode(FILE *fp, int GWidth, int GHeight,
int GInterlace, int Background, int Transparent,
int BitsPerPixel, unsigned char *cmap, ifunptr GetPixel );
void main(int ac, char **av){
int k;
int GWidth;
int GHeight;
FILE *fp;
int GInterlace= 0;
int Background;
int Transparent;
int BitsPerPixel= -1;

char *cp;
static int xpar[3]= {-1,-1,-1};
static int bg[3]= {0,-1,-1};
char *srcname= 0;
char *dstname= 0;

while(cp= *++av)if(*cp++=='-')switch(*cp++){
case 'n': c666= 1; break;
case 'c': comment= *++av; break;
// case 'p': BitsPerPixel= atoi(*++av);
// if(BitsPerPixel>8)
// BitsPerPixel= 8;
// break;
case 'i': GInterlace= 1; break;
case 'x': xpar[0]= atoi(*++av);
if(av[1][0]>='0' && av[1][0]<='9'){
xpar[1]= atoi(*++av);
xpar[2]= atoi(*++av);
} break;
case 'b': bg[0]= atoi(*++av);
if(av[1][0]>='0' && av[1][0]<='9'){
bg[1]= atoi(*++av);
bg[2]= atoi(*++av);
} break;
default:
erra: for(av= note; *av; ++av)
fprintf(stderr, "%s\n", *av);
exit(1);
}else if(srcname==0)
srcname= *av;
else if(dstname==0)
dstname= *av;
else
goto erra;
if(dstname==0)
goto erra;

/* Open the source bmp */
gulp(srcname);

/* Choose the output colors */
ncolors= formoutputcmap();
for(BitsPerPixel= 0; (1 << BitsPerPixel)<ncolors; BitsPerPixel++);
gulp(srcname);

/* Create the gif file */
fp= fopen(dstname, "wb");
if(fp==0){
perror(dstname);
exit(1);
}
/* Transfer some parameters */
GWidth= (int)bi.biWidth;
GHeight= (int)bi.biHeight;
Transparent= xpar[0];
if(xpar[1]>=0)
Transparent= used[nearestcolor(xpar)];
Background= bg[0];
if(bg[1]>=0)
Background= used[nearestcolor(bg)];

GIFEncode(fp, GWidth, GHeight,
GInterlace, Background, Transparent,
BitsPerPixel, omap, GetPixel);

printf("%d colors in %s\n", ncolors, srcname);
}
/*****************************************************************************
*
* GIFENCODE.C - GIF Image compression interface
*
* GIFEncode( FName, GHeight, GWidth, GInterlace, Background, Transparent,
* BitsPerPixel, Red, Green, Blue, GetPixel )
*
*****************************************************************************/
#define TRUE 1
#define FALSE 0

static int Width, Height;
static int curx, cury;
static long CountDown;
static int Pass = 0;
static int Interlace;
typedef int code_int;

#ifdef SIGNED_COMPARE_SLOW
typedef unsigned long int count_int;
typedef unsigned short int count_short;
#else /*SIGNED_COMPARE_SLOW*/
typedef long int count_int;
#endif /*SIGNED_COMPARE_SLOW*/

static void Putword ( int w, FILE* fp );
static void compress ( int init_bits, FILE* outfile, ifunptr ReadValue );
static void output ( code_int code );
static void cl_block ( void );
static void cl_hash ( count_int hsize );
static void writeerr ( void );
static void char_init ( void );
static void char_out ( int c );
static void flush_char ( void );


/*
* Bump the 'curx' and 'cury' to point to the next pixel
*/
static void BumpPixel() {
/* Bump the current X position */
++curx;

/*
* If we are at the end of a scan line, set curx back to the beginning
* If we are interlaced, bump the cury to the appropriate spot,
* otherwise, just increment it.
*/
if( curx == Width ) {
curx = 0;
if( !Interlace )
++cury;
else {
switch( Pass ) {
case 0:
cury += 8;
if( cury >= Height ) {
++Pass;
cury = 4;
} break;
case 1:
cury += 8;
if( cury >= Height ) {
++Pass;
cury = 2;
} break;
case 2:
cury += 4;
if( cury >= Height ) {
++Pass;
cury = 1;
} break;
case 3:
cury += 2;
break;
}
}
}
}

/*
* Return the next pixel from the image
*/
static int GIFNextPixel(ifunptr getpixel){
int r;

if( CountDown == 0 )
return EOF;
--CountDown;

r = ( * getpixel )( curx, cury );
BumpPixel();
return r;
}

/* public */
static void GIFEncode(FILE *fp, int GWidth, int GHeight,
int GInterlace, int Background, int Transparent,
int BitsPerPixel, unsigned char *omap, ifunptr GetPixel ){

int B;
int RWidth, RHeight;
int LeftOfs, TopOfs;
int Resolution;
int ColorMapSize;
int InitCodeSize;
int i;

Interlace = GInterlace;

ColorMapSize = 1 << BitsPerPixel;

RWidth = Width = GWidth;
RHeight = Height = GHeight;
LeftOfs = TopOfs = 0;

Resolution = BitsPerPixel;

/* Calculate number of bits we are expecting */
CountDown = (long)Width * (long)Height;

/* Indicate which pass we are on (if interlace) */
Pass = 0;

/* The initial code size */
if( BitsPerPixel <= 1 )
InitCodeSize = 2;
else
InitCodeSize = BitsPerPixel;

/* Set up the current x and y position */
curx = cury = 0;

/* Write the Magic header */
fwrite_chk( Transparent < 0 ? "GIF87a" : "GIF89a", 1, 6, fp );

/* Write out the screen width and height */
Putword( RWidth, fp );
Putword( RHeight, fp );

/* Indicate that there is a global colour map */
B = 0x80; /* Yes, there is a color map */

/* OR in the resolution */
B |= (Resolution - 1) << 5;

/* OR in the Bits per Pixel */
B |= (BitsPerPixel - 1);

/* Write it out */
fputc( B, fp );

/* Write out the Background colour */
fputc( Background, fp );

/* Byte of 0's (future expansion) */
fputc( 0, fp );

/* Write out the Global Colour Map */
for( i=0; i<ColorMapSize; ++i ) {
fputc( omap[0], fp ); // Red
fputc( omap[1], fp ); // Green
fputc( omap[2], fp ); // Blue
omap += 3;
}
/* Write out extension for transparent colour index, if necessary. */
if ( Transparent >= 0 ) {
fputc( '!', fp );
fputc( 0xf9, fp );
fputc( 4, fp );
fputc( 1, fp );
fputc( 0, fp );
fputc( 0, fp );
fputc( Transparent, fp );
fputc( 0, fp );
}
if (comment!=0 && *comment){
fputc( '!', fp);
fputc( 0xfe, fp);
fputc( strlen(comment), fp);
do
fputc( *comment, fp);
while(*comment++);
}
/* Write an Image separator */
fputc( ',', fp );

/* Write the Image header */
Putword( LeftOfs, fp );
Putword( TopOfs, fp );
Putword( Width, fp );
Putword( Height, fp );

/* Write out whether or not the image is interlaced */
if( Interlace )
fputc( 0x40, fp );
else
fputc( 0x00, fp );

/* Write out the initial code size */
if(EOF==fputc( InitCodeSize, fp )){
perror("Writing output");
exit(1);
}
/* Go and actually compress the data */
compress( InitCodeSize+1, fp, GetPixel );

/* Write out a Zero-length packet (to end the series) */
fputc( 0, fp );

/* Write the GIF file terminator */
fputc( ';', fp );

/* And close the file */
fclose( fp );
}

/* Write out a word to the GIF file */
static void Putword(int w, FILE *fp ){
fputc( w & 0xff, fp );
fputc( (w / 256) & 0xff, fp );
}
/***************************************************************************
*
* GIFCOMPR.C - GIF Image compression routines
*
* Lempel-Ziv compression based on 'compress'. GIF modifications by
* David Rowley (mgardi@watdcsu.waterloo.edu)
*
***************************************************************************/

/* General DEFINEs */

#define BITS 12
#define HSIZE 5003 /* 80% occupancy */

#ifdef NO_UCHAR
typedef char char_type;
#else /*NO_UCHAR*/
typedef unsigned char char_type;
#endif /*NO_UCHAR*/

/*
*
* GIF Image compression - modified 'compress'
*
* Based on: compress.c - File compression ala IEEE Computer, June 1984.
*
* By Authors: Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas)
* Jim McKie (decvax!mcvax!jim)
* Steve Davies (decvax!vax135!petsd!peora!srd)
* Ken Turkowski (decvax!decwrl!turtlevax!ken)
* James A. Woods (decvax!ihnp4!ames!jaw)
* Joe Orost (decvax!vax135!petsd!joe)
*
*/
#include <ctype.h>

#define ARGVAL() (*++(*argv) || (--argc && *++argv))

static int n_bits; /* number of bits/code */
static int maxbits = BITS; /* user settable max # bits/code */
static code_int maxcode; /* maximum code, given n_bits */
static code_int maxmaxcode = (code_int)1 << BITS; /* should NEVER generate this code */
#ifdef COMPATIBLE /* But wrong! */
# define MAXCODE(n_bits) ((code_int) 1 << (n_bits) - 1)
#else /*COMPATIBLE*/
# define MAXCODE(n_bits) (((code_int) 1 << (n_bits)) - 1)
#endif /*COMPATIBLE*/

static count_int htab [HSIZE];
static unsigned short codetab [HSIZE];
#define HashTabOf(i) htab[i]
#define CodeTabOf(i) codetab[i]

static code_int hsize = HSIZE; /* for dynamic table sizing */

/*
* To save much memory, we overlay the table used by compress() with those
* used by decompress(). The tab_prefix table is the same size and type
* as the codetab. The tab_suffix table needs 2**BITS characters. We
* get this from the beginning of htab. The output stack uses the rest
* of htab, and contains characters. There is plenty of room for any
* possible stack (stack used to be 8000 characters).
*/

#define tab_prefixof(i) CodeTabOf(i)
#define tab_suffixof(i) ((char_type*)(htab))[i]
#define de_stack ((char_type*)&tab_suffixof((code_int)1<<BITS))

static code_int free_ent = 0; /* first unused entry */

/*
* block compression parameters -- after all codes are used up,
* and compression rate changes, start over.
*/
static int clear_flg = 0;

static int offset;
static long int in_count = 1; /* length of input */
static long int out_count = 0; /* # of codes output (for debugging) */

/*
* compress stdin to stdout
*
* Algorithm: use open addressing double hashing (no chaining) on the
* prefix code / next character combination. We do a variant of Knuth's
* algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime
* secondary probe. Here, the modular division first probe is gives way
* to a faster exclusive-or manipulation. Also do block compression with
* an adaptive reset, whereby the code table is cleared when the compression
* ratio decreases, but after the table fills. The variable-length output
* codes are re-sized at this point, and a special CLEAR code is generated
* for the decompressor. Late addition: construct the table according to
* file size for noticeable speed improvement on small files. Please direct
* questions about this implementation to ames!jaw.
*/

static int g_init_bits;
static FILE* g_outfile;

static int ClearCode;
static int EOFCode;

static void compress(int init_bits, FILE *outfile, ifunptr ReadValue ){
register long fcode;
register code_int i /* = 0 */;
register int c;
register code_int ent;
register code_int disp;
register code_int hsize_reg;
register int hshift;

/*
* Set up the globals: g_init_bits - initial number of bits
* g_outfile - pointer to output file
*/
g_init_bits = init_bits;
g_outfile = outfile;

/*
* Set up the necessary values
*/
offset = 0;
out_count = 0;
clear_flg = 0;
in_count = 1;
maxcode = MAXCODE(n_bits = g_init_bits);

ClearCode = (1 << (init_bits - 1));
EOFCode = ClearCode + 1;
free_ent = ClearCode + 2;

char_init();

ent = GIFNextPixel( ReadValue );

hshift = 0;
for ( fcode = (long) hsize; fcode < 65536L; fcode *= 2L )
++hshift;
hshift = 8 - hshift; /* set hash code range bound */

hsize_reg = hsize;
cl_hash( (count_int) hsize_reg); /* clear hash table */

output( (code_int)ClearCode );

#ifdef SIGNED_COMPARE_SLOW
while ( (c = GIFNextPixel( ReadValue )) != (unsigned) EOF ) {
#else /*SIGNED_COMPARE_SLOW*/
while ( (c = GIFNextPixel( ReadValue )) != EOF ) { /* } */
#endif /*SIGNED_COMPARE_SLOW*/

++in_count;

fcode = (long) (((long) c << maxbits) + ent);
i = (((code_int)c << hshift) ^ ent); /* xor hashing */

if ( HashTabOf (i) == fcode ) {
ent = CodeTabOf (i);
continue;
} else if ( (long)HashTabOf (i) < 0 ) /* empty slot */
goto nomatch;
disp = hsize_reg - i; /* secondary hash (after G. Knott) */
if ( i == 0 )
disp = 1;
probe:
if ( (i -= disp) < 0 )
i += hsize_reg;

if ( HashTabOf (i) == fcode ) {
ent = CodeTabOf (i);
continue;
}
if ( (long)HashTabOf (i) > 0 )
goto probe;
nomatch:
output ( (code_int) ent );
++out_count;
ent = c;
#ifdef SIGNED_COMPARE_SLOW
if ( (unsigned) free_ent < (unsigned) maxmaxcode) {
#else /*SIGNED_COMPARE_SLOW*/
if ( free_ent < maxmaxcode ) { /* } */
#endif /*SIGNED_COMPARE_SLOW*/
CodeTabOf (i) = free_ent++; /* code -> hashtable */
HashTabOf (i) = fcode;
} else
cl_block();
}
/*
* Put out the final code.
*/
output( (code_int)ent );
++out_count;
output( (code_int) EOFCode );
}

/*****************************************************************
* TAG( output )
*
* Output the given code.
* Inputs:
* code: A n_bits-bit integer. If == -1, then EOF. This assumes
* that n_bits =< (long)wordsize - 1.
* Outputs:
* Outputs code to the file.
* Assumptions:
* Chars are 8 bits long.
* Algorithm:
* Maintain a BITS character long buffer (so that 8 codes will
* fit in it exactly). Use the VAX insv instruction to insert each
* code in turn. When the buffer fills up empty it and start over.
*/

static unsigned long cur_accum = 0;
static int cur_bits = 0;

static unsigned long masks[] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F,
0x001F, 0x003F, 0x007F, 0x00FF,
0x01FF, 0x03FF, 0x07FF, 0x0FFF,
0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF };

static void
output( code )
code_int code;
{
cur_accum &= masks[ cur_bits ];

if( cur_bits > 0 )
cur_accum |= ((long)code << cur_bits);
else
cur_accum = code;

cur_bits += n_bits;

while( cur_bits >= 8 ) {
char_out( (unsigned int)(cur_accum & 0xff) );
cur_accum >>= 8;
cur_bits -= 8;
}

/*
* If the next entry is going to be too big for the code size,
* then increase it, if possible.
*/
if ( free_ent > maxcode || clear_flg ) {

if( clear_flg ) {

maxcode = MAXCODE (n_bits = g_init_bits);
clear_flg = 0;

} else {

++n_bits;
if ( n_bits == maxbits )
maxcode = maxmaxcode;
else
maxcode = MAXCODE(n_bits);
}
}

if( code == EOFCode ) {
/*
* At EOF, write the rest of the buffer.
*/
while( cur_bits > 0 ) {
char_out( (unsigned int)(cur_accum & 0xff) );
cur_accum >>= 8;
cur_bits -= 8;
}

flush_char();

fflush( g_outfile );

if( ferror( g_outfile ) )
writeerr();
}
}

/*
* Clear out the hash table
*/
static void
cl_block () /* table clear for block compress */
{

cl_hash ( (count_int) hsize );
free_ent = ClearCode + 2;
clear_flg = 1;

output( (code_int)ClearCode );
}

static void
cl_hash(hsize) /* reset code table */
register count_int hsize;
{

register count_int *htab_p = htab+hsize;

register long i;
register long m1 = -1;

i = hsize - 16;
do { /* might use Sys V memset(3) here */
*(htab_p-16) = m1;
*(htab_p-15) = m1;
*(htab_p-14) = m1;
*(htab_p-13) = m1;
*(htab_p-12) = m1;
*(htab_p-11) = m1;
*(htab_p-10) = m1;
*(htab_p-9) = m1;
*(htab_p-8) = m1;
*(htab_p-7) = m1;
*(htab_p-6) = m1;
*(htab_p-5) = m1;
*(htab_p-4) = m1;
*(htab_p-3) = m1;
*(htab_p-2) = m1;
*(htab_p-1) = m1;
htab_p -= 16;
} while ((i -= 16) >= 0);

for ( i += 16; i > 0; --i )
*--htab_p = m1;
}

static void
writeerr()
{
err( "error writing output file" );
}

/******************************************************************************
*
* GIF Specific routines
*
******************************************************************************/

/*
* Number of characters so far in this 'packet'
*/
static int a_count;

/*
* Set up the 'byte output' routine
*/
static void char_init(){
a_count = 0;
}

/*
* Define the storage for the packet accumulator
*/
static char accum[ 256 ];

/*
* Add a character to the end of the current packet, and if it is 254
* characters, flush the packet to disk.
*/
static void
char_out( int c ){
accum[ a_count++ ] = c;
if( a_count >= 254 )
flush_char();
}
/*
* Flush the packet to disk, and reset the accumulator
*/
static void flush_char(){
if( a_count > 0 ) {
fputc( a_count, g_outfile );
fwrite_chk( accum, 1, a_count, g_outfile );
a_count = 0;
}
}
/*
**
** Based on GIFENCOD by David Rowley <mgardi@watdscu.waterloo.edu>.A
** Lempel-Zim compression based on "compress".
**
** Modified by Marcel Wijkstra <wijkstra@fwi.uva.nl>
**
**
** Copyright (C) 1989 by Jef Poskanzer.
**
** The Graphics Interchange Format(c) is the Copyright property of
** CompuServe Incorporated. GIF(sm) is a Service Mark property of
** CompuServe Incorporated.
*/
/****************************************************************************** Windows functions, types, and definitions *
* Version 3.10 *
* Copyright (c) 1985-1992, Microsoft Corp. All rights reserved. *
*******************************************************************************
*
*(C)1996 Ephraim Cohen--subject to the above,
** permission to use, copy, modify, and distribute this software and its
** documentation for any purpose and without fee is hereby granted, provided
** that the above copyright notices appear in all copies and that both that
** copyright notice and this permission notice appear in supporting
** documentation. This software is provided "as is" without express or
** implied warranty.
**
*/



bush 2000-12-18
  • 打赏
  • 举报
回复
GATESGO@21CN.COM
bzshow 2000-12-18
  • 打赏
  • 举报
回复
從現在開始賣錢。
1角錢一個源碼。
bzshow 2000-12-16
  • 打赏
  • 举报
回复
不用謝,資源共享嘛!
terrywang 2000-12-16
  • 打赏
  • 举报
回复
收到,感谢
bzshow 2000-12-15
  • 打赏
  • 举报
回复
其實這個zip文件里還有 24bit的bmp to 8bit的bmp的源碼,
還有gif2bmp的源碼!
bzshow 2000-12-15
  • 打赏
  • 举报
回复
ok,我現在就發給你!
terrywang 2000-12-15
  • 打赏
  • 举报
回复
TERRYWANGYU@SINA.COM
1 , TaskBar_v0.5.zip"Form_Taskbar is a control for Visual Basic which, once placed onto a form, makes the form act like the Taskbar (minus the Start Menu)." -- David Newcum2 , RemBuilderplus.zip"Rem Builder will auto load on startup to use Rem Builder; start your Visual Basic program with your project code showing, right click and you should see "Rem Builder".3 , syntax.zipThis is an excellent example of how to highlight HTML code in a rich textbox. I encourage everyone to check it out.4 , status.zipThis example demonstrates how to display text about each control the mouse is currently above.5 , dm10e.zipThis COM object allows you to send SMTP mail from many of the most used applications, including:Active Server Pages (Microsoft IIS or Chili!ASP extensions) Microsoft Visual Basic 4.x/5.x/6.x Microsoft Word, Access, Excel 95/97 (VBA) Windows Scripting Host (cscript / wscript) Perl 5.x for Win32 Inprise Delphi 4 Microsoft Visual C++ 4.x/5.x/6.x Microsoft Visual J++ 1.x/6.0 (Java) 6 , ocxex.zip"This is a quick example I made to show you how to use Events and properties in a OCX."7 , news.exeThis control aids as a complete Newsgroup control. It can post messages and recieve messages through the internet.8 , optiondemo.zipThis example demonstrates how to create realistic Option Buttons in Visual Basic.9 , mencrypt.zipThis ocx allows you to encrypt strings while utilizing a password shift method.10 , listtxt.zipThis shows how to retrieve the text from the current selection in a listbox.11 , list_index.zipThis example tells you if the inputted List Index is selected or not.12 , fade.zipThis is a bas to fade a pictuerbox. Can be used to make a progressbar13 , subcls32.zipThis demonstrates hoe to write a subclassing control. And it has many examples as to how to use the control (included.)14 , djmeter.zipThis is the source for a Progress Bar control. Also includes a helpful example.15 , progress.zipThis is an example on how to use the Progress Bar included with Microsoft's Visual Basic.16 , slider.zip"This is a sample of the Slider control that is part of the Microsoft Windows Common Controls(COMCTL32.OCX). "17 , statusbar.zip"This is a sample of the StatusBar control that is part of the Microsoft Windows Common Controls(COMCTL32.OCX). "18 , tabstrip.zip"This is a sample of the TabStrip control that is part of the Microsoft Windows Common Controls(COMCTL32.OCX). "19 , uncommondialog.zipThis is an alternative to Microsoft's (tm) Common Dialog control by Nick Mancini.20 , ucmdex.zipThis is the example to go with Uncommon Dialog OCX.21 , scroll.zipThis demonstrates how to create an auto-scrolling textbox.22 , splitter.zipThis demonstrates how to "split" controls. This is an excellent example, and I reccomend this file for everyone. 23 , mtymse.zip"This project is a fully working ActiveX control, with code, that allows you to control almost every aspect of the mouse. You can move the mouse, click the buttons and adjust the click time from your application."24 , ucmdsrc.zipThis is the source to my OCX. This demontrates how to create a basic OCX. This will aid anyone who wants to create an OCX.25 , avb-systray.zipThis is a good example to add your programs' icon to the Systray. This Zip also includes a helpful example.26 , cmdex.zipThis is an example of how to use the Common Dialog. This demonstrates most of the event procedures of the CM Dialog control.27 , campbell-reg.zipThis demonstrates how to write and retrieve information from the registry.28 , basChangeCursor.zipThis module demonstrates how to animate your cursor through Visual Basic, and Win32.29 , hdcat.zipThis will grab every file on your hard drive and add its path to a listbox.30 , vbo_bump.zipThis DLL allows programmers to easily draw 3D grippers and lines on Device Contexts (DC). 31 , vbo_user32_bas.zipThis BAS file contains many functions to ease the process of using the USER32 DLL. 32 , vbo_gdi32_bas.zipThis BAS File conatains many functions to ease the process of using the GDI32 DLL. 33 , vbo_button_bas.zipThis bas contains functions to manipulate Button class objects34 , LPT_Port.zipRead/write to LPT parallel port35 , DancingBaby.zipA Dancing Baby Screen Saver Which Dance on A Famous Song Macarena ( With Sound ) A Very Cute Screen Saver ,with source code, If you want more avi files then please mail me.36 , superwriter.zipA complete Wordprocessor, with source code. You can save, open files, print them out, copy, cut, paste, well you know the concept!37 , LogOff.zipThis conveniently placed program allows you to log off from your system tray.38 , ChPass.zipChanges NT Domain Passord. This program has two compenants... a server and a a client. The Server must run on a Domain Controller.39 , Reboot.zipThis conveniently placed program allows you to restart your computer more easily, from your system tray. 40 , analogclock.zipThis is a very good demo OCX for an analog clock. Although quite big in size, this is due to the very good background to the clock face. The analog click itself is very accurate and looks very impressive.41 , edge.zipThis program uses a few API calls/functions to set 3D, sunken and etched effects to an image inside an image control. It also has an example of how to change a label control to a 3D command button.42 , splitpanel2.zipA re-written version of the SplitPanel that David originally put onto this site about a year ago. It basically is a control that you place on a form and you can put other controls on the form and by dragging the splitpanel bar around, it does the resizing for you. 43 , avcontrol.zipThis control takes care of many audio and visual functions needed for game and graphical programmers. You can easily retrieve or change the screen resolution and color depth, play audio CDs and standard wave files 44 , fsocontrol.zipThis demonstration version of this control is a wrapper around the FileSystemObject - and makes using the FSO much easier.45 , slidingtoolbar.zipThis project shows how to implement a sliding toolbar in an application using one quick Kernel32 API function "Sleep". The application is fairly simple and easy to implement. 46 , dcsize.zipWhen this control is put onto a form, it ensures that all other controls retain the correct aspect-ratio from the design time view. Basically, it resize all controls on a form when the form resizes. This code is 100% free.47 , colorchooseocx.zipThis great OCX allows you to have a drop down list of colors to allow your user to choose from. The control itself has all the events and properties that you need.48 , xgraphmeter.zipThis is XGraphMeter, a bargraph/meter control good for displaying constantly changing values such as CPU usage or DUN throughput.49 , dynlistmnu.zipWhile trying to come up with a Dynamic menu in VB, I decided that VBs menu object was just too much of a pain to work with This project contains a form to mimic the functionality that I was looking for.. Part of my design criteria was that the menu form 50 , runtime.zipSupposedly, what this code does cannot be done... But it works. Basically, its a demonstration of how you can change control properties at run-time. If you try it in VB, you will get a runtime error, but this code shows you how to do it. Gilbert says51 , ledbulb.zipThis is a first for this author. Its an OCX which represents a characters in the form of led bulbs.52 , textapiroutines.basContained here is a small set of routines can be used with a Rich Text box (RTF) control. It can be used for other controls as well with minor modifications. You are welcome to change, use and distribute the code as you see fit.53 , xflatbutton.zipFlatButton is an owner-drawn flat button that pops up when the mouse passes over it. This version is text-only, but has flexible color support.54 , urllabel.zipWith the development of the internet and intranet applications, this control could could in more and more useful. Its a hyperlink label which will change color or underline when the mouse goes over it 55 , progbar.zipThis is a great replacement for the standard VB progress bar. Its smooth, totally free (all the source code is here), and more versitile than the one that comes with VB.56 , splitpanel.zipThis little control with full source code is remarkably compact but does a lot of fancy things. It allows you to be able to split panels and handles all the resizing behind it. We couldn't think of how to describe it properly, but 下载 it and try it57,basicreg.zipBasic Save and Retrieve Functions58,proguse.zipKeep Track of a Programs Usage59,millisec.zipCount Time in Milliseconds 60,getday.zipGet the Day of Week that a Day Falls On61,shellend.zipNotify the User when a Shelled Process Ends 62,varlist.zipGet a List of Windows Variables 63,detdisp.zipDetermine Display Colors 64,ctrlntwk.zipControl Panel - Network65,ctrluser.zipControl Panel - User Properties66,ctrltwui.zipControl Panel - TweakUI67,ctrlthm.zipControl Panel - Themes68,ctrltele.zipControl Panel - Telephony69,ctrlsys.zipControl Panel - System Properties70,ctrlscrn.zipControl Panel - Screen Savers71,ctrlreg.zipControl Panel - Regional Settings72,ctrlprnt.zipControl Panel - Printers73,ctrlpwr.zipControl Panel - Power Management74,ctrlpw.zipControl Panel - Passwords75,ctrlodbc.zipControl Panel - ODBC3276,ctrlmm.zipControl Panel - Multimedia77,ctrlmdm.zipControl Panel - Modem78,ctrlkbd.zipControl Panel - Keyboard79,ctrlmous.zipControl Panel - Mouse80,ctrlpoa.zipControl Panel - Post Office Admin81,ctrlotlk.zipControl Panel - Outlook82,ctrljoy.zipControl Panel - Joystick83,ctrlie4.zipControl Panel - Internet Explorer 84,ctrlgame.zipControl Panel - Game Controllers85,ctrlfont.zipControl Panel - Fonts86,ctrlarmp.zip Control Panel - Add/Remove Programs87,ctrlanh.zipControl Panel - Add New Hardware88,ctrlanp.zipControl Panel - Add New Printer89,ctrlaccs.zipControl Panel - Accessibility90,ctrlbrf.zipControl Panel - Create Briefcase91,ctrlcdsk.zipControl Panel - Copy Disk92,ctrlcns.zipControl Panel - Create New Shortcut93,ctrldun.zipControl Panel - Dial-Up Networking94,ctrldisp.zipControl Panel - Display Properties95,RegControl.zipFree Registry ActiveX Control. Read/Write String/Binary/DWord values, Check if key/value exists, CreateKey, Delete key/value and enumerate keys/values!96,MouseEvent.zipThis is a Mouse Event procedure that is pretty cool. It can be used for Web designing. Check it out!97,ShellTrayIcon.zipThe CShellTrayIcon class allows your VB application to set, change and delete icons in the system's tray 98,Reboot2.zipReboot remotely. I wrote this to reboot selected PC's during off hours. It is a standalone application that will display a 10 second countdown. Any open data will try to be saved prior to the shutdown process.99,S-Secure.zipThis is S-Secure.....a security program I've coded for Windows. It has 4 modules each in a separate VB project. 100,DriveSpace.zipThis Program finds and displays the Drive's Space.101,Disable_X.zipThis user control allows you to disable the windows close "X" button. Example program included.102,SetParnt.zipShows how to assign controls to different forms at run time. 103,phone.zipA Cellular Phone Application Uses MSCOMM, Modem and normal telephone lines to make calls. You can use this application to make local as well as International calls. 104,Timer01.zipSimple program demonstrating how to create a stop watch using the Timer control. 105,Bubblesort.zipA simple Bubble Sort code that shows how the program works within a VB program. 106,systray.zipJust another Systray Utility, but worse than the others !!! static, flashing and animated Tray-Icons 107,FolderFiles.zipDemonstrates usage of progress bar and list box controls. Its purpose is to get all the files from a specified folder while showing the progress completed. 108,MultipleDataSets.zipThis is a simple, (1) form VB 6.0 program which demonstrates how to plot multiple sets of data on the same graph using the MSChart Control 6.0 (OLEDB). 109,MthVwPrj.zipMonthView control. Lets users view and set date information via a calendar-like interface. 110,calculator4.zipI know this is wierd but I made a calculator control. Just add it to your control bar, double click, and you can use the calculator when your project is at run-time. Source included.111,GradientButton.zipThis button was created to be an enhanced replacement for Visual Basic's standard command button by adding 2 more Border appearance schemes, 2 more button styles, and hover effects. 112,MSChart.zipMSChart. You can view MSChart in Line graph,Pie , Area, etc.. also you can update data provided in the Grid.. Very interesting must see it... 113,printing_tut.zipI made this for a freind to help him out with some basic Printing, i got the idea from a printing tut i found on the net, so the code is not mine. 114,treeview.zipThis code can as many child nodes to a tree view control and can save the data and structure of the treeview control in a text file. Later the data and structure can be retrieved from the text file and filled in the tree view control by clicking the load button. 115,alarm_clock.zipIt simulates an alarm clock. 116,DesktopByAlexDrankus.zipThis program hides/shows desktop, hides/shows taskbar, hides it self from the ctrl+alt+delete, uses pictures to create the forms (pretty cool forms) and many other functions just place this program and all components in a sub-folder 117,Label3D.zipLabel3D lets you change the Label Face Color Shadow Color ON/OFF Shadow. 118,HotLinks.zip Custom Control which acts like a text box, except the developer can specify hot links in the control which act like web page links allowing users to click them, while allowing the developer full control over the result of the click. 119,custbutt.zipThis application shows how to create non rectangular buttons. 120,grid.zipComplete grid coded in vb. supports : locked rows/columns , fg/bg colors , text alignment , cell-edge styles , different selectionstyles . texbox/dropdown cells , cell icons and lots more... 121,analogmeter.zipCreate your own analog meters using MSPaint. These .bmp or .gif files become your meter face. Use the (analogmeter) subroutine to automatically draw the meter needle over the meter face 122,wheel.zipSpinWheel control to be used in place of either the UpDown control or the ScrollBar control.123,ArielBrowseFolder.zipA browse folder control resembling a combobox. When the dropdown button is clicked, browse through a folder treeview to select a directory. Uses the SHBrowseForFolder function, amongst other APIs. A call back procedure is implemented showing the currently selected folder in the browse for folder dialog. 124,pp_prj.zipThis program shows you how to create a sample project that adds print preview capabilities to your Visual Basic program by using a generic object and the Printer object. 125,popup.zipPopUp buttons with only 4 lines of code. 126,adbevel.zipThe bevel control in Delphi is now available in VB. 127,rainbow.zipCool! Have a ProgressBar like in InstallShield!With free selectable fore- and backcolor and the percent value displayed in the middle!Check it out.128,gb12.zipWell folks. Another version of Gold Button is here. I've added a few things. Here they are: Property descriptions, MaskColor, UseMask, Base Address in OCX, picture will now automatically align with text and when you are in desing mode and OnUp property is bsNone, a Dash-Dot-Dot box is drawn over the button, so you can see th button's area. 129,gb11.zipA new version of Gold Button is here dudes.New version has Picture Property and Skin Support. 130,BIGDOGMEDIA.zipMEDIA PLAYER THAT SUPPORTS FORMATS LIKE MP3,AVI,MPEG,WAV ECT.EXAMPLE OF USING ANIMATION WHEN PLAYER IS LAUNCHED. 131,HTML.zipAn HTML editor with complete VB source code. 132,PrintPreview1.zipPrint Setup, and Print Priview application. 133,RTFEditor.zipRTF text editor, HTML text editor, web browser, and more...Try it. Note, make sure your printer is turned on before running the application. 134,VBExplorer-II.zipVBExplorer file utility application. This application uses the Visual Basic TreeView and ListView controls to create a file management application similar to Windows Explorer.135,resizepic.zipShows how to resize a picture box control on a form at run time.

2,586

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 资源
社区管理员
  • 资源
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧