Commit c5ff5563 authored by kirov's avatar kirov
Browse files

Further dvelopment.



git-svn-id: https://scm.blissgarden.org/svn/lima/trunk@27 45c4679d-1946-429d-baad-37912b19538b
parent 0982d95b
......@@ -17,9 +17,10 @@ struct GaussPeak {
class FrameBuilder {
public:
int m_bin_X, m_bin_Y;
int m_bin_X, m_bin_Y; // use Bin calss!
FrameDim m_frame_dim;
FrameBuilder();
FrameBuilder( int bin_X, int bin_Y, FrameDim &frame_dim,
std::vector<struct GaussPeak> &peaks, double grow_factor );
......@@ -33,8 +34,10 @@ class FrameBuilder {
private:
std::vector<struct GaussPeak> m_peaks;
double m_grow_factor;
unsigned long m_frame_nr;
int writeFrameData( unsigned char *ptr );
double dataXY( int x, int y );
};
......
#include <ctime>
#include <cstdio>
#include <fstream>
#include <unistd.h>
#include <sys/time.h>
......@@ -51,7 +52,7 @@ int BufferSave::writeEdfHeader( const FrameInfoType &finfo,
BufferSave::BufferSave( const string &prefix, enum FileFormat format ) :
prefix(prefix), format(format)
m_prefix(prefix), m_format(format)
{
}
......@@ -63,14 +64,17 @@ BufferSave::~BufferSave( )
int BufferSave::writeFrame( FrameInfoType &finfo )
{
string name=this->prefix;
string name;
char num_str[64];
if( name.find(".edf") == string::npos )
name += ".edf";
name = m_prefix;
snprintf(num_str, 63, "%06lu", finfo.acq_frame_nb);
name += string(num_str);
name += ".edf";
ofstream file(name.c_str(), ios_base::out | ios_base::binary);
if( this->format == FMT_EDF )
if( m_format == FMT_EDF )
writeEdfHeader(finfo, file);
file.write((char *)finfo.frame_ptr, finfo.width*finfo.height*finfo.depth);
......
......@@ -27,8 +27,8 @@ enum FileFormat {
class BufferSave {
public :
std::string prefix;
enum FileFormat format;
std::string m_prefix;
enum FileFormat m_format;
BufferSave( const std::string &prefix, enum FileFormat format );
~BufferSave( );
......
......@@ -11,17 +11,18 @@ using namespace lima;
int main( void )
{
FrameBuilder fb;
FrameDim fd = fb.m_frame_dim;
int width = fd.getSize().getWidth();
int height = fd.getSize().getHeight();
int depth = fd.getDepth();
BufferSave bs("boza", FMT_EDF);
FrameInfoType finfo;
unsigned char *buffer;
FrameDim fd = fb.m_frame_dim;
FrameInfoType finfo;
buffer = NULL;
try {
int size = fd.getSize().getWidth()*
fd.getSize().getHeight()*
fd.getDepth();
int size = width * height * depth;
buffer = new unsigned char[size];
} catch( bad_alloc& ) {
goto end;
......@@ -32,9 +33,9 @@ int main( void )
finfo.acq_frame_nb = fb.getFrameNr();
finfo.frame_ptr = buffer;
finfo.width = fd.getSize().getWidth();
finfo.height = fd.getSize().getHeight();
finfo.depth = fd.getDepth();
finfo.width = width;
finfo.height = height;
finfo.depth = depth;
finfo.frame_time_stamp = 0; /* XXX */
bs.writeFrame(finfo);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment