00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CFL_TOOLCILIMAGE_H
00016 #define CFL_TOOLCILIMAGE_H
00017
00018 #include <cfl/ScanBaseBuffer.h>
00019
00020 #include <cil/Image.h>
00021
00022 #if _MSC_VER > 1000
00023 #pragma once
00024 #endif // _MSC_VER > 1000
00025
00026
00027
00028
00029 typedef cil::Image< CScanBaseBuffer::ValueType > Image;
00030
00031
00032
00033
00034 inline cil::Size2D ToRadius( int x, int y )
00035 {
00036 return cil::Size2D( ( x - 1 ) / 2, ( y - 1 ) / 2 );
00037 }
00038
00039
00040
00041
00042 inline cil::Region2D ToRegion( const CRect& rcArea )
00043 {
00044 return cil::Region2D(
00045 cil::Point2D( rcArea.left, rcArea.top ),
00046 cil::Size2D ( rcArea.Width(), rcArea.Height() ) );
00047 }
00048
00049
00050
00051
00052 inline Image ToImage( CScanBaseBufferPtr lpScanBuffer, bool bDoR2L = false )
00053 {
00054
00055
00056
00057
00058
00059 typedef CScanBaseBuffer::SizeType SizeType;
00060
00061 SizeType rows = lpScanBuffer->Rows();
00062 const SizeType columns = lpScanBuffer->Columns();
00063 const SizeType offset = lpScanBuffer->GetPartialFrameOffset();
00064 const SizeType count = lpScanBuffer->GetPartialFrameSize();
00065
00066
00067
00068
00069
00070
00071 if ( 0 != count )
00072 {
00073 rows = count / columns;
00074 }
00075
00076 return Image(
00077 lpScanBuffer->Data() + bDoR2L * lpScanBuffer->GetFrameSize() + offset,
00078 cil::Size2D( columns, rows )
00079 );
00080 }
00081
00082
00083
00084
00085 inline Image ToImage( CScanBaseBufferPtr lpScanBuffer, bool bDoR2L, const CRect& rcArea )
00086 {
00087 return Image(
00088 lpScanBuffer->Data() + bDoR2L * lpScanBuffer->GetFrameSize(),
00089 cil::Size2D( lpScanBuffer->Columns(), lpScanBuffer->Rows() ), ToRegion( rcArea )
00090 );
00091 }
00092
00093 #endif // #ifndef CFL_TOOLCILIMAGE_H
00094
00095
00096
00097
00098