ccd.cpp
来自「用VC編的數碼相機仿真程序 包括圖像的預處理 DCT變換 壓縮等 最后可用ver」· C++ 代码 · 共 71 行
CPP
71 行
/*
* writen by shikosan
* File name: ccd.cpp
* 仿真CCD
*/
#include "ccd.h"
#include <stdio.h>
#define SZ_ROW 64
#define SZ_COL (128 + 2)
static FILE *imageFileHandle;
// change char into unsigned char by shikosan
// static char buffer[SZ_ROW][SZ_COL];
static unsigned char buffer[SZ_ROW][SZ_COL];
static int rowIndex, colIndex;
// This function is passed name of image file
void CcdInitialize(const char *imageFileName)
{
imageFileHandle = fopen(imageFileName, "r");
rowIndex = -1;
colIndex = -1;
}
// This file reads “image” from file
void CcdCapture(void)
{
// change int to uchar
unsigned char pixel;
rewind(imageFileHandle);
for(rowIndex=0; rowIndex<SZ_ROW; rowIndex++)
{
for(colIndex=0; colIndex<SZ_COL; colIndex++)
{
if( fscanf(imageFileHandle, "%i", &pixel)==1 )
{
// buffer[rowIndex][colIndex] = (char)pixel
buffer[rowIndex][colIndex] = (unsigned char)pixel; // Change char into uchar 4-24-2008
}
}
}
rowIndex = 0;
colIndex = 0;
}
// This function outputs pixels one at a time
// Change char into uchar
// char CcdPopPixel(void)
unsigned char CcdPopPixel(void)
{
// Change char into uchar
unsigned char pixel;
//char pixel;
pixel = buffer[rowIndex][colIndex];
if( ++colIndex == SZ_COL )
{
colIndex = 0;
if( ++rowIndex == SZ_ROW )
{
colIndex = -1;
rowIndex = -1;
}
}
return pixel;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?