📄 ccd.cpp
字号:
/*
* 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -