123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- #include "stdafx.h"
- #include "OTSScanBase.h"
- #include <atlimage.h>
- namespace OTSController {
- COTSScanBase::COTSScanBase()
- : m_pnFrameStore(NULL)
- , m_nFrameStoreSizeWords(0)
- , m_nScanStepSize(0)
- , m_nPixelDwell(0)
- , m_nInterPixelDwell(0)
- , m_nNumberOfReads(0)
- , m_nMatrix(0)
- , m_dMag(0)
- , m_bIsSimuation(FALSE)
- {
- m_fieldSizes[0] = CSize(64, 50);
- m_fieldSizes[1] = CSize(128, 100);
- m_fieldSizes[2] = CSize(256, 200);
- m_fieldSizes[3] = CSize(512, 400);
- m_fieldSizes[4] = CSize(1024, 800);
- m_fieldSizes[5] = CSize(2048, 1600);
- m_fieldSizes[6] = CSize(4096, 3200);
- }
- COTSScanBase::~COTSScanBase()
- {
- }
- // get image from a file
- CBSEImgPtr COTSScanBase::AcquireBSEImageFromBitmapFile()
- {
- // prepare file
- CFile file;
- CFileException fe;
- BYTE* m_pPixel;
- BYTE* m_pBmInfo;
- BITMAPFILEHEADER* m_pBmfh;
- m_pBmfh = new BITMAPFILEHEADER;
- CBSEImgPtr bseImage;
- // get simulation image file name
- CString strOTSSysDataPath = GetCompanySysDataPathName();
- CString strBitmapFilePathName = strOTSSysDataPath + SIMULATION_IMAGE_FILEPATH + _T("\\") + SIMULATION_IMAGE_FILENAME;
-
-
- // check if the file exist
- if (Exists(strBitmapFilePathName))
- {
- if (!file.Open(strBitmapFilePathName, CFile::modeRead, &fe))
- {
- LogInfoTrace(__FILE__, __LINE__, _T("COTSEDSBase::AcquireBSEImageFromBitmapFile: failed to open simulation image file %s."), strBitmapFilePathName);
- return nullptr;
- }
- // read file header
- file.Read(m_pBmfh, sizeof(BITMAPFILEHEADER));
- m_pBmInfo = new BYTE[m_pBmfh->bfOffBits - 14];
- file.Read(m_pBmInfo, m_pBmfh->bfOffBits - 14);
- BITMAPINFOHEADER bmih;
- memcpy(&bmih, m_pBmInfo, sizeof(BITMAPINFOHEADER));
- long width = bmih.biWidth;//获取宽度
- int bitCount = bmih.biBitCount;//获取位数
- long height = bmih.biHeight;//获取高度
- long LineBytes = (width * bitCount + 31) / 32 * 4;//计算每行像素所占的字节数
- m_pPixel = new BYTE[height * LineBytes];
- file.Read(m_pPixel, height * LineBytes);
- file.Close();
- CRect imageRect(0, 0, width, height);
- bseImage=CBSEImgPtr(new CBSEImg(imageRect));
-
- /*bseImage->SetImageRect(imageRect);*/
- bseImage->InitImageData(width, height);
- BYTE* pImageData = bseImage->GetImageDataPointer();
- long nActImageSize = width * height;
- for (int i = 0; i < height; i++)
- {
- memcpy(pImageData + i * width, m_pPixel + (height - i) * width, width);
- }
- delete[]m_pPixel;
- delete[]m_pBmInfo;
- delete m_pBmfh;
-
- }
- else
- {
- LogInfoTrace(__FILE__, __LINE__, _T("COTSEDSBase::AcquireBSEImageFromBitmapFile: failed to open simulation image file %s."), strBitmapFilePathName);
- return nullptr;
- }
- return bseImage;
- }
-
-
- // get max size index
- int COTSScanBase::GetMaxSizeIndex(void)
- {
- int nRet = (sizeof(m_fieldSizes) / sizeof(CSize) - 1);
- return nRet;
- }
- // bruker scan test
- BOOL COTSScanBase::IsBruker()
- {
- BOOL BRet = (GetType() == ScanController::SCANNER_ID::BRUKER);
- return BRet;
- }
- }
|