1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- #include "StdAfx.h"
- #include "OcrBase.h"
- OcrBase::OcrBase()
- {
- m_pBits = NULL;
- m_LimitedSize.cx = 0;
- m_LimitedSize.cy = 0;
- m_PixesCount = 0;
- }
- OcrBase::OcrBase(SIZE size)
- {
- m_LimitedSize = size;
- m_PixesCount = size.cx*size.cy;
- m_pBits = new BYTE[size.cx*size.cy*sizeof(OCRCOLOR)];
- }
- OcrBase::OcrBase(PBYTE pBits,SIZE size)
- {
- m_LimitedSize = size;
- m_PixesCount = size.cx*size.cy;
- m_pBits = new BYTE[size.cx*size.cy*sizeof(OCRCOLOR)];
- memcpy(m_pBits,pBits,size.cx*size.cy*sizeof(OCRCOLOR));
- }
- OcrBase::~OcrBase(void)
- {
- delete []m_pBits;
- }
- BOOL RectContainPt(RECT Area,POINT Pt)
- {
- if(Pt.x > Area.right || Pt.x < Area.left || Pt.y > Area.bottom || Pt.y < Area.top)
- {
- return FALSE;
- }
- return TRUE;
- }
- BOOL CheckTwoColors(OCRCOLOR color1,OCRCOLOR color2,OCRCOLOR diff)
- {
- short X1;
- short X2;
- short D1;
- short DH;
- short DL;
- X1 = (short)GetRValue(color1);
- X2 = (short)GetRValue(color2);
- D1 = (short)GetRValue(diff);
- DH = X1 + D1;
- DL = X1 - D1;
- if(X2 < DL || X2 > DH)
- {
- return FALSE;
- }
- X1 = (short)GetGValue(color1);
- X2 = (short)GetGValue(color2);
- D1 = (short)GetGValue(diff);
- DH = X1 + D1;
- DL = X1 - D1;
- if(X2 < DL || X2 > DH)
- {
- return FALSE;
- }
- X1 = (short)GetBValue(color1);
- X2 = (short)GetBValue(color2);
- D1 = (short)GetBValue(diff);
- DH = X1 + D1;
- DL = X1 - D1;
- if(X2 < DL || X2 > DH)
- {
- return FALSE;
- }
- return TRUE;
- }
|