Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > C/C++ программирование > Общие вопросы C/C++
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 03.04.2008, 12:54   #1
MIKI
Пользователь
 
Регистрация: 31.03.2008
Сообщений: 14
Восклицание Алгоритм упаковывания изображения

Простите што я с Украини и помогите пожалуста очень надо!!!!!!!!!!!!


алгоритм упаковывания и сжимание изображений - сохранение изображения экрана в фале и отображения файла на экран.

Требования к програме:
1) прога должна иметь интерфейс в виде окон и меню для выбора режимов ее работы
2) предусмотреть загрузку графического файла в окно екрана и его запись на диск
3) управление режимами работы программы выполнить с помощью клавиатуры и мыши
MIKI вне форума Ответить с цитированием
Старый 21.04.2008, 14:37   #2
MIKI
Пользователь
 
Регистрация: 31.03.2008
Сообщений: 14
По умолчанию

Народ Пожалуйста помогите очень надо!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
MIKI вне форума Ответить с цитированием
Старый 23.04.2008, 05:55   #3
mig-29
Пользователь
 
Регистрация: 03.04.2008
Сообщений: 10
По умолчанию

в нато не надо было вступать...
mig-29 вне форума Ответить с цитированием
Старый 04.06.2008, 20:09   #4
MIKI
Пользователь
 
Регистрация: 31.03.2008
Сообщений: 14
По умолчанию

Народ пожалуйста помогите найти и исправить ошибки
Код:
#define HT_SIZE                 8192
#define HT_KEY_MASK             0x1FFF
#define HT_KEY_NUM_BITS         13 
#define HT_MAX_KEY              8191 
#define HT_MAX_CODE             4095      
#define HT_GET_KEY(l)      (l >> 12) 
#define HT_GET_CODE(l)     (l & 0x0FFF) 
#define HT_PUT_KEY(l)      (l << 12) 
#define HT_PUT_CODE(l)     (l & 0x0FFF)
unsigned long *initHashTable(void);
void  clearHashTable (unsigned long *table);
void  insertHashTable(unsigned long *table, unsigned long Key, int Code);
int   existsHashTable(unsigned long *table, unsigned long Key) ;
#include <io.h> 
#include <fcntl.h> 
#include <stdio.h> 
#include <string.h> 
#include <alloc.h> 
#include <sys\stat.h> 
#include "hash.h"
static int KeyItem(unsigned long Item);
unsigned long *hashTable;
unsigned long *initHashTable(void) {
unsigned long *table;
table=(unsigned long*) malloc(HT_SIZE*sizeof(long));
if (table==NULL) return NULL;
clearHashTable (table);
return table;
}
void clearHashTable(unsigned long *table) {
memset(table, 0xFF, HT_SIZE * sizeof(long));
}
void insertHashTable (unsigned long *table, unsigned long Key, int Code) {
int HKey = KeyItem(Key);
unsigned long *HTable = table;
while (HT_GET_KEY(HTable[HKey]) =- 0xFFFFFL) 	HKey =(HKey + 1) & HT_Key_MASK;
HTable[HKey] = HT_PUT_KEY(Key) | HTPUT_CODE(Code);
}
int existsHashTable(unsigned long *table, unsigned long Key) {
int HKey = KeyItem(Key);
unsigned long *HTable = table, HTKey;
while ((HTKey = HT_GET_KEY(HTable[HKey])) != 0xFFFFFL) {
if (Key == HTKey)
return HT_GET_CODE(HTable[HKey]) ;
HKey = (HKey + 1) & HT_KEY_MASK;
}
return -1;
}
static int KeyItem(unsigned long Item) {
return ((Item >> 12) ^ Item) & HT_KEY_MASK;
}                                
#ifndef __GIF_H 
#define __GIF_H
struct GIFScreenDesc {
int width, height;
unsigned char dif;
unsigned char fonColor;
char nulls;
};
#define HAS_GMAP(r)    		(((r).dif & 0х80) !=0)
#define RESOLUTION (г)   		((((r).dif & 0х70)>>4)+1)
#define MAXCOLOR(r)    		(((r).dif & 0х07)+1)
struct GIFImageDesc {
int left, top, width, height;
unsigned char dif;
};
#define IMAGE_DESC 			0x2C
#define USE_GMAP(r)    		(((r).dif & 0х80)==0)
#define SEQUENCE(r)    		(((r).dif & 0х40)==0)
#endif
#include <stdio.h> 
#include "hash.h" 
#include "ega.h" 
#include "gif.h"
#define MIN(a,b) 			((a) < (b) ? (a) : (b) )
#define LZ_MAX_CODE 		4095 
#define FLUSH_OUT   		4096 
#define FIRST_CODE 			4097
static unsigned char buffer[256];               
int outByte(FILE *fp, unsigned char *buffer, int code) {
if (code==FLUSH_OUT) {
if (buffer[0] != 0)    fwrite(buffer,1,buffer[0]+1,fp);
buffer[0]=0;
fwrite(buffer,1,1,fp) ;
}
else {
if (buffer[0]==255) {
fwrite(buffer,1,buffer[0]+1,fp) ;
buffer[0]=0; }
buffer[++buffer[0]]=code;
}
return 1;
}
static int
curBufferShift,bitsPerPixel,                      
clearCode,                       
EOFCode,			       
pixel, 					
maxCodeMult2,
runningBits,			 
runCode,					
curCode, newCode; 				
static unsigned long
newKey,        					
codeBuffer,					
pixelCount; 						
extern unsigned long *hashTable;
int GIFCompressCode(FILE *fp,int code) {
if (code==FLUSH_OUT) {
while (curBufferShift>0) {
outByte(fp, buffer, (int) (codeBuffer & 0xFF));
codeBuffer>>=8;
curBufferShift-=8 ; }
curBufferShift=0;
outByte(fp,buffer,FLUSH_OUT) ; }
else {
codeBuffer |= ((long) code) << curBufferShift;
curBufferShift += runningBits;
while (curBufferShift >= 8) {
				outByte(fp,buffer,codeBuffer&&0xFF) ;  
codeBuffer >>= 8;
curBufferShift -= 8; }
}                                 
	if (runCode >= maxCodeMult2 && code <= 4095) maxCodeMult2 = 1<<++runningBits;
return 1;
}
int GIFCompressLine(FILE *fp, unsigned char *line, int lineLen) {
int i=0;
if (curCode==FIRST_CODE) curCode=line[i++] ;
while (i<lineLen) {
			pixel=line[i++] ;   
		newKey = (((unsigned long) curCode)<<8)+pixel;   
if((newCode=existsHashTable(hashTable,newKey))>=0) 
curCode=newCode ;
else {
          	                 GIFCompressCode(fp,curCode) ;
                 	curCode=pixel;                
                   if (runCode >= LZ_MAX_CODE) {
GIFCompressCode(fp,clearCode) ;
runCode=EOFCode+1;
runningBits=bitsPerPixel+1;
maxCodeMult2 = 1<<runningBits;
clearHaahTable (hashTable);
}
else  insertHashTable(hashTable,newKey,runCode++);
}
}
if (pixelCount==0) {
GIFCompressCode (fp,curCode) ;
GIFCompressCode(fp,EOFCode) ;
GIFCompressCode(fp,FLUSH_OUT) ;
}
return 1;
}
}

Последний раз редактировалось merax; 04.06.2008 в 20:50.
MIKI вне форума Ответить с цитированием
Старый 04.06.2008, 20:09   #5
MIKI
Пользователь
 
Регистрация: 31.03.2008
Сообщений: 14
По умолчанию

Код:
int GIFInitCompress (FILE *fp, struct GIFImageDesc *d) {
bitsPerPixel=RESOLUTION(*d);
*buffer=(bitsPerPixel<2) ?  2 : bitsPerPixel;
fwrite(&buffer,1,1,fp) ;
buffer[0]=0;
clearCode=1<<bitsPerPixel;
EOFCode= clearCode+1;
runCode=EOFCode+1 ;
runningBits=bitsPerPixel+1;
maxCodeMalt2=1<<runningBits;
curBufferShift=0;
codeBuffer=0;
initHashTable() ;
GIFCompressCode(fp,clearCode);           
return 1 ;
}
{
unsigned char *colors);
int k, i ;
unsigned char pl1,pl2,pl3,pl4;
unsigned char *mc=colors;
for (k=0; k<plLen; k++) {
pl1=planes[k];
pl2=planes[k+plLen];
pl3=planes[k+2*plen];
pl4=planes[k+3*ppln];
for (i=0; i<8; i++) {
*mc=8*((0x80>>i)&pl1)+4*((0x80>>i)&pl2)+2*((0x80>>i)&pl3)+
((0x80>>i)&pl4) ; 
mc++; 
}
} 
}
unsigned char planes[4*80];
unsigned char colors[640];
void GIFSave(char *fileName) {
struct GIFScreenDesc screenD;
struct GIFImageDesc imageD;
FILE *fp;
char com;
char label[8]="GIF87a";
char *globColorMap;
int colorMapLen;
int resolution, maxColors,y;
unsigned char *colors;
int useLocalMap, H, seq, maxColor;
fp=fopen(fileName,"wb") ;
if (fp==NULL) return;
screenD.width   =640; 
screenD.height  =350; 
screenD.fonColor=  0; 
screenD.nulls   =  0;
screenD.dif=0x33;
fwrite(&label,1,6,fp);
fwrite(&screenD,1,7,fp);
com=IMAGE_DESC;
fwrite(&com,1,1,fp) ;
imageD.left    =  0;
imageD.top     =  0;
imageD.width   =640;
imageD.height  =350;
imageD.dif=0x03;
fwrite(&screenD,1,9,fp);
GIFInitCompress(&screenD, &imageD);
for (y=0; y<350; y++) {
EGAReadLine(planes,80,y);
EGAConvertPlanes(planes,80,colors);
GIFCompressLine(fp,colors,640);
}
fclose(fp);
}
moderator: Используйте тег <CODE>

Последний раз редактировалось merax; 04.06.2008 в 20:53.
MIKI вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Изображения в WebBrowser. Teen4jump Работа с сетью в Delphi 3 15.08.2008 12:13
Чтение изображения из базы данных, Вместо изображения - "System.Byte[]" ruelCrow Общие вопросы .NET 3 10.07.2008 23:29
Вращение изображения beginner JavaScript, Ajax 5 07.07.2008 23:44
Алгоритм упаковывания изображения MIKI Фриланс 7 06.04.2008 20:03
Изображения в БД alikon1 БД в Delphi 3 08.10.2007 13:13