⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fbitio.c

📁 傅立叶变换和小波变换是图像压缩的重要工具。该代大戏是利用小波变换进行图像压缩。
💻 C
字号:
#include <crblib/inc.h>
#include <stdio.h>

/*protos:*/

struct FileBitIOInfo * FileBitIO_Init(FILE * OutF);
void FileBitIO_CleanUp(struct FileBitIOInfo * BII);
long FileBitIO_FlushWrite(struct FileBitIOInfo * BII); /*returns length of data*/

const int BFileBitIOReadBitMask = 0x80;

struct FileBitIOInfo
  {
	FILE * FP;
	int OutLen;
  int BitBuffer;
  int BitsToGo;
  };

/*
 *  Allocate and init a BII
 *  for reads, FileBitIO_InitRead must also be called
 *
 */
struct FileBitIOInfo * FileBitIO_Init(FILE * inFP)
{
struct FileBitIOInfo * BII;

if ( (BII = malloc(sizeof(struct FileBitIOInfo))) == NULL )
  return(NULL);

BII->FP = inFP;
BII->OutLen = 0;
BII->BitBuffer = 0;
BII->BitsToGo = 8;

return(BII);
}

/*
 *  Free a BII after it has been written or read from
 *  call FileBitIO_FlushWrite before writing to a file
 *
 */
void FileBitIO_CleanUp(struct FileBitIOInfo * BII)
{
free(BII);
}

/*
 *  FlushWrite sticks remaining bits into BitArray
 *  must be called before writing BitArray
 *  returns length of array to write
 *
 */
long FileBitIO_FlushWrite(struct FileBitIOInfo * BII)
{
if ( BII->BitsToGo < 8 )
  {
  BII->BitBuffer <<= BII->BitsToGo;
	fputc(BII->BitBuffer,BII->FP);
	BII->OutLen++;

  BII->BitsToGo = 8;
  BII->BitBuffer = 0;
  /* keep going, if you like */
  }

fflush(BII->FP);

return( BII->OutLen );
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -