Текущий архив: 2005.10.02;
Скачать: CL | DM;
Вниз
Сжатие RLE или HEX для bmp Найти похожие ветки
← →
Eraser © (2005-01-27 15:23) [0]Посоветуйте пожалуйста хорошие компоненты/алгоритмы для сжатия bmp простыми и быстрыми алгоритмами (RLE или HEX например).
Очень благодарен!
← →
miek © (2005-01-27 16:58) [1]Zlib
← →
Eraser © (2005-01-27 21:36) [2]miek ©
Это у меня есть...
← →
test1 (2005-02-02 22:45) [3]Бери TGA формат, там есть поддержка RLE
← →
dmk © (2005-02-03 00:52) [4]
void decode ()
{
int ch, i;
while (1)
{
ch=fgetc(fpin);
if (feof(fpin) || ferror(fpin))
break;
if (ch > 127)
{
i = ch - 127; /* i is the number of repetitions */
/* get the byte to be repeated */
ch = fgetc(fpin);
if (feof(fpin) || ferror(fpin))
{
puts("\nERROR: premature end of file\n");
break;
}
/* uncompress a chunk */
for ( ; i ; i--)
fputc(ch, fpout);
}
else
{
/* copy out some uncompressed bytes */
i = ch + 1; /* i is the no. of bytes */
/* uncompress a chunk */
for ( ; i ; i--)
{
ch = fgetc(fpin);
if (feof(fpin) || ferror(fpin))
{
puts("\nERROR: premature end of file\n");
break;
}
fputc(ch, fpout);
}
}
} /* end while */
}
← →
dmk © (2005-02-03 00:52) [5]
void encode ()
{
int ret_code;
tmpbuf_cnt = 0; /* no. of char"s in tmpbuf */
outbuf_cnt = 0; /* no. of char"s in outbuf */
while (1)
{
if (get_byte() == EOF) /* read next byte into ch */
break;
tmpbuf[++tmpbuf_cnt] = (unsigned char) ch;
if (tmpbuf_cnt == 3)
{
/* see if all 3 match each other */
if ((tmpbuf[1] == tmpbuf[2])
&& (tmpbuf[2] == tmpbuf[3]))
{
/* they do - add compression */
/* this will process all bytes in input file until
a non-match occurs, or 128 bytes are processed,
or we find eof */
ret_code=process_comp();
if (ret_code == EOF_FOUND)
break; /* stop compressing */
if (ret_code == NON_MATCH)
tmpbuf_cnt=1; /* save the char that didn"t match */
else
/* we just compressed the max. of 128 bytes */
tmpbuf_cnt=0; /* start over for next chunk */
}
else
{
/* we know the first byte doesn"t match 2 or more
others, so just send it out as uncompressed. */
process_uncomp(tmpbuf[1]);
/* see if the last 2 bytes in the buffer match */
if (tmpbuf[2] == tmpbuf[3])
{
/* move byte 3 to position 1 and pretend we just
have 2 bytes -- note that the first byte was
already sent to output */
tmpbuf[1]=tmpbuf[3];
tmpbuf_cnt=2;
}
else
{
/* send byte 2 and keep byte 3 - it may match the
next byte. Move byte 3 to position 1 and set
count to 1. Note that the first byte was
already sent to output */
process_uncomp(tmpbuf[2]);
tmpbuf[1]=tmpbuf[3];
tmpbuf_cnt=1;
}
}
}
} /* end while */
flush_outbuf();
}
← →
Chaser © (2005-02-03 09:59) [6]Eraser, не могли бы Вы выслать алгоритм zlib?
Буду признателен.
chaser@front.ru
← →
miek © (2005-02-03 14:38) [7]Zlib идет в комплекте с Delphi, начиная где-то с 3-ей версии.
← →
Hokum (2005-05-13 14:55) [8]А исходник или програму RLE кодирования не скинете? ;)
← →
XProger © (2005-05-13 15:59) [9]Hokum, а ты четвёртый пост не заметил? ;)
← →
Hokum (2005-05-14 14:56) [10]Нет, и не замечаю, по крайней мере он почемуто не пашет.
← →
Hokum (2005-05-14 14:59) [11]Поэтоиу спрашиваю програму.
← →
XProger © (2005-05-15 15:31) [12]Hokum, а разобраться в коде не пробовал?
P.S.
Долой лентяев!
← →
Hokum (2005-05-15 22:36) [13]XProger, пытался. Да только с Delphi работую только 3 месяца. Поэтому и не всегда получается все понять.
P.S.
Да ладно чего тебе стоит.
Страницы: 1 вся ветка
Текущий архив: 2005.10.02;
Скачать: CL | DM;
Память: 0.5 MB
Время: 0.039 c