// FileBuffer.cpp: implementation of the CFileBuffer class.
|
//
|
//////////////////////////////////////////////////////////////////////
|
|
#include "stdafx.h"
|
#include "InspectionBuffer.h"
|
|
#ifdef _DEBUG
|
#undef THIS_FILE
|
static char THIS_FILE[]=__FILE__;
|
#define new DEBUG_NEW
|
#endif
|
|
//////////////////////////////////////////////////////////////////////
|
// Construction/Destruction
|
//////////////////////////////////////////////////////////////////////
|
|
void CFileBuffer::FillBuffer(CFile &file, int x, int y, int oWidth, int oHeight)
|
{
|
int iData= sizeof(BITMAPFILEHEADER)+ sizeof(BITMAPINFOHEADER)+ 1024;
|
for(int i= 0; i< m_Height; i++)
|
{
|
// fseek(pFile, iData+ x+ (y+ i)*oWidth, SEEK_SET);
|
// fread(m_pData+ i*GetDataWidth(), width, 1, pFile);
|
file.Seek(iData+ x+ (y+ i)*oWidth, SEEK_SET);
|
file.Read(m_pData+ i*GetDataWidth(), m_Width);
|
}
|
}
|
|
void CFileBuffer::FillBufferReverse(CFile &file, int x, int y, int oWidth, int oHeight)
|
{
|
int iData= sizeof(BITMAPFILEHEADER)+ sizeof(BITMAPINFOHEADER)+ 1024;
|
|
int nNewY = oHeight - y - m_Height;
|
for(int i= m_Height-1; i>=0 ; i--)
|
{
|
file.Seek(iData+ x+ (nNewY+ i)*oWidth, SEEK_SET);
|
file.Read(m_pData+ (m_Height-1-i)*GetDataWidth(), m_Width);
|
}
|
}
|
|
void CFileBuffer::FillBufferFromTwoFile(CFile &file1, CFile &file2, int x, int y, int FirstHeight, int SecondHeight, int oWidth, int oHeight)
|
{
|
int iData= sizeof(BITMAPFILEHEADER)+ sizeof(BITMAPINFOHEADER)+ 1024;
|
for(int i= 0; i< FirstHeight; i++)
|
{
|
file1.Seek(iData+ x+ (y+ i)*oWidth, SEEK_SET);
|
file1.Read(m_pData+ i*GetDataWidth(), m_Width);
|
}
|
|
if(SecondHeight>0)
|
{
|
for(int i= 0; i< SecondHeight; i++)
|
{
|
file2.Seek(iData+ x+ i*oWidth, SEEK_SET);
|
file2.Read(m_pData+ (FirstHeight+i)*GetDataWidth(), m_Width);
|
}
|
}
|
}
|
|
|
void CFileBuffer::SaveBufferToTwoFile(CFile &file1, CFile &file2, int x, int y, int FirstHeight, int SecondHeight, int oWidth, int oHeight)
|
{
|
int iData= sizeof(BITMAPFILEHEADER)+ sizeof(BITMAPINFOHEADER)+ 1024;
|
for(int i= 0; i< FirstHeight; i++)
|
{
|
file1.Seek(iData+ x+ (y+ i)*oWidth, SEEK_SET);
|
file1.Write(m_pData+ i*GetDataWidth(), m_Width);
|
}
|
|
if(SecondHeight>0)
|
{
|
for(int i= 0; i< SecondHeight; i++)
|
{
|
file2.Seek(iData+ x+ i*oWidth, SEEK_SET);
|
file2.Write(m_pData+ (FirstHeight+i)*GetDataWidth(), m_Width);
|
}
|
}
|
}
|
|
// miniont, 2008-09-04, begin
|
BITMAPINFOHEADER CFileBuffer::GetBitmapInfoHeader(CFile &file)
|
{
|
BITMAPINFOHEADER infoHeader;
|
|
file.Seek(sizeof(BITMAPFILEHEADER), SEEK_SET);
|
file.Read(&infoHeader, sizeof(BITMAPINFOHEADER));
|
|
return infoHeader;
|
}
|
|
const int CFileBuffer::GetContentWidth(CFile &file)
|
{
|
BITMAPINFOHEADER infoHeader;
|
|
file.Seek(sizeof(BITMAPFILEHEADER), SEEK_SET);
|
file.Read(&infoHeader, sizeof(BITMAPINFOHEADER));
|
|
return infoHeader.biWidth;
|
}
|
|
|
const int CFileBuffer::GetContentHeight(CFile &file)
|
{
|
BITMAPINFOHEADER infoHeader;
|
|
file.Seek(sizeof(BITMAPFILEHEADER), SEEK_SET);
|
file.Read(&infoHeader, sizeof(BITMAPINFOHEADER));
|
|
return infoHeader.biHeight;
|
}
|
// miniont, 2008-09-04, end
|