« Previous : 1 : 2 : 3 : 4 : 5 : Next »
사용자 삽입 이미지

 CXTPToolBar* pToolBarCombo = pCommandBars->Add(_T("Combo"), xtpBarTop);
 pToolBarCombo->SetBarID(IDR_MAINFRAME + 3);
 
 CXTPControlColorBoxCB* pControlCombo = new CXTPControlColorBoxCB;
 pToolBarCombo->GetControls()->Add(pControlCombo); //(xtpControlComboBox, ID_FILE_NEW);
 {
       pControlCombo->SetColorBoxMode();
       int nIndex=pControlCombo->AddString(_T("White"));
       pControlCombo->SetBoxColor(nIndex,RGB(255,255,255),RGB(0,0,0));

       nIndex=pControlCombo->AddString(_T("Red"));
       pControlCombo->SetBoxColor(nIndex,RGB(255,0,0),RGB(0,0,255));

       nIndex=pControlCombo->AddString(_T("Black"));
       pControlCombo->SetBoxColor(nIndex,RGB(0,0,0),RGB(192,192,192));
       pControlCombo->SetCurSel(0);
 }

Posted by chungki

2009/09/02 10:32 2009/09/02 10:32
,
Response
No Trackback , No Comment
RSS :
http://www.chungki.net/tc/rss/response/288

사용자 삽입 이미지

사용법
#include 
using namespace Gdiplus;

#include "ReportRecordBoxItem.h"
#include "ReportRecordItemBoxText.h"


 COLORREF Fill,Edge;
 CXTPReportRecord* pRecord=new CXTPReportRecord;
 pRecord->AddItem(new CReportRecordItemBox(Fill, Edge));
 pRecord->AddItem(new CReportRecordItemBoxText(Fill, Edge, _T("ABCDEFG")));

Posted by chungki

2009/09/02 10:26 2009/09/02 10:26
,
Response
No Trackback , No Comment
RSS :
http://www.chungki.net/tc/rss/response/287

STL의 string의 대소문자 변환

std::string strSome = "AaBbCcDdEeFfGg"; 

// 대문자로.. 
std::transform(strSome.begin(), strSome.end(), strSome.begin(), toupper); 

// 소문자로.. 
std::transform(strSome.begin(), strSome.end(), strSome.begin(), tolower);

Posted by chungki

2009/09/02 10:24 2009/09/02 10:24
,
Response
No Trackback , No Comment
RSS :
http://www.chungki.net/tc/rss/response/286

CString을 이용한 Token처리

다음은 CString을 이용한 Token처리 방법 예제입니다.

 Example

 
 
CString str(_T("%First Second#Third")); 
CString resToken; 
int curPos= 0; 
resToken= str.Tokenize("% #",curPos); 

while (resToken != "")
 { 
        printf("Resulting token: %s\n", resToken); 
        resToken= str.Tokenize("% #",curPos); 
}; 
 

 Output

 Resulting Token: First
 Resulting Token: Second
 Resulting Token: Third

Posted by chungki

2009/09/02 10:22 2009/09/02 10:22
,
Response
No Trackback , No Comment
RSS :
http://www.chungki.net/tc/rss/response/285

STL를 이용한 Sorting

STL를 이용하면 간단하게 Sorting기능을 구현할 수 있다. 다음은 Point데이터를 X축기준으로 Sorting하는예제이다.
#include   
  
struct SPOINT3d  
{  
public:  
  
     SPOINT3d() {}  
     SPOINT3d(double _x, double _y, double _z) : x(_x), y(_y),z(_z) {}  
  
public:  
  
     double x;  
     double y;  
     double z;  
};  
  
typedef std::vector      pointsettype;  
  
// Sort연산자 구조체  
struct XSorter  
{  
     bool operator(const SPOINT3d& p1, const SPOINT3d& p2)  
     {  
           return (p1.x 여기서 조건문을 바꾸면 y,z기준으로 혹은 역방향으로 Sorting이 가능하다.  
     }  
};  
  
void main()  
{  
     pointsettype TPointSet;  
  
    // 데이터 삽입  
    TPointSet.push_back(SPOINT3d(0., 0., 0.));  
    TPointSet.push_back(SPOINT3d(1., 0., 0.));  
    TPointSet.push_back(SPOINT3d(2., 0., 0.));  
    TPointSet.push_back(SPOINT3d(3., 0., 0.));  
    TPointSet.push_back(SPOINT3d(4., 0., 0.));  
  
     // Sorting  
     std::sort(TPointSet.begin(), TPointSet.end(), XSorter());  
       
}  

Posted by chungki

2009/09/02 10:14 2009/09/02 10:14
,
Response
No Trackback , No Comment
RSS :
http://www.chungki.net/tc/rss/response/284

Token 사용예제

"1, 2, 3, 5, 6"같은 문자열로부터 숫자값을 꺼내오기 위해서는 다음과 같은 방법을 사용할 수 있다.

char* str="1,2,3,5,6";

int a[5];
sscanf(str,"%d,%d,%d,%d,%d",&a[0],&a[1],&a[2],&a[3],&a[4]);


하지만 문자열부터 꺼내오는 데이터개수가 고정적이지가 않을때는 sscanf사용하는게 불편하다. 그리고 그래서 Token을 이용하면 개수가 정해지지 않은 데이터를 가져올 수 있다. 다음은 token의 사용예제이다.

 
char string[]= "A string of ,,tokens and some more tokens"; 
char seps[]=" ,w"; 
char *token;

void main(void) 
{     
     printf("%s Tokens:", string);     
     token=strtok(string,seps);     
     while (token!=NULL)     
     {     
            printf(" %s",token);        
            token=strtok(NULL,seps);     
      } 
}

 Output

 A string of ,,tokens
and some more tokens

 Tokens:
A
String
of
tokens
and
some
more
tokens

Posted by chungki

2009/09/02 10:12 2009/09/02 10:12
Response
No Trackback , No Comment
RSS :
http://www.chungki.net/tc/rss/response/283

MFC에서 GDIPlus사용하기

MFC에서 GDIPlus를 사용하기 위해서는 다음과 같은 내용으로 세팅하시면 됩니다.

1. stdafx.h 파일에 다음 2줄 추가

#include <gdiplus.h>

using namespace Gdiplus;

2. APP 클래스 헤더에 멤버 추가


  ULONG_PTR m_gdiplusToken;

3. APP InitInstance()함수에 추가

 

GdiplusStartupInput gdiplusStartupInput;

GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);

4. APP ExitInstance()함수에 추가

 

GdiplusShutdown(m_gdiplusToken);

5. 프로젝트 세팅에 Debug모드와 Release모드각각에

   gdiplus.lib 추가

Posted by chungki

2009/09/02 10:07 2009/09/02 10:07
, ,
Response
No Trackback , No Comment
RSS :
http://www.chungki.net/tc/rss/response/282

[ImageEngine] Lesson2

1. Type Define

typedef char		s8;
typedef unsigned char 	u8;
typedef short 		s16;
typedef unsigned short  u16;
typedef long		s32;
typedef unsigned long  u32;
typedef float		f32;
typedef double		f64;


2.Structure Define
struct SGRAY8 
{
 union
 {
  u8 val;
  u8 m[1];
 };
}; 

struct SGRAY16 {  union  {   u16 val;   u16 m[1];  }; };

struct SRGB8 {  union  {   struct   {    u8 r;    u8 g;    u8 b;   };   u8 m[3];  }; };

struct SRGB16 {  union  {   struct   {    u16 r;    u16 g;    u16 b;   };   u16 m[3];  }; };

Posted by chungki

2008/03/04 00:20 2008/03/04 00:20
Response
No Trackback , No Comment
RSS :
http://www.chungki.net/tc/rss/response/261

[ImageEngine] Lesson 1


Image Types

항 목

내용

비고

Bilevel Images

Black and White(B/W)


Graysclae Image

Shades of gray

 

Palette-color Images

Use Index into a full RGB-lookup table

16 color

256 color

RGB Full Color Images

Be made up of three components: red, green, blue

24bit Color

RGBA Full Color Images

Be made up of four components: red, green, blue, alpha

32bit Color


Image Property

항 목

내용

비고

Width

The number of columns in the Image(the number of pixels per scanline)


Length(Height)

The number of rows in the Image

 

WidthByte

Size of byte per row

 

SamplesPerPixe(SPP)

The number of components per pixel.(This number is 3 for RGB images)

8/16bit mages

Sample = Channel

BitsPerSample(BPS)

Number of bits per component

BitsPerPixel(BPP)

Number of bits per Pixel ( BPP = SPP * BPS)

 

BytePerPixel(BPP)

Number of bytes per Pixel ( BytePerPixel = BitsPerPixel * 8)

 

BandCount

The number of band

 

Define Pixel

 

사용자 삽입 이미지


Declare Pixel Classes


사용자 삽입 이미지




Posted by chungki

2008/02/27 17:01 2008/02/27 17:01
Response
No Trackback , No Comment
RSS :
http://www.chungki.net/tc/rss/response/259

세점을 지나는 원 구하기



세점을 지나는 원은 외접원이다. 결국 외접원(CircumCircle)을 구하면 되는 것이다.
원을 구하기 위해서는 중심점과 반지름을 구하면 된다.

Circumcircle


외접원의 중심점은 외심과 같다. 그래서 외심을 구하면 되는 건데 수학적으로 외심은
세변의 수직이등분선이 교차하는 점이다. 문제는 이걸 어떻게 코딩으로 구현하냐는 것이다.

가장 간단한 방법은 중심점으로부터 세 점의 거리가 서로 같다는 식을 세워놓고 연립방정식을 풀면 된다. 두번째 방법으로는 Woflram MathWorld 홈페이지를 참고한다.  두번째 방법으로 하자. ㅎㅎ

다음은 ARmaxSDK 2007에 들어가 있는 기본구조체소스이다.

기본구조체 (Language : cpp)
  1. /// 2차원 점 템플릿 구조체
  2. template <class _TX,int _Type=0>
  3. struct mt_POINT2
  4. {     
  5.     union     
  6.     {         
  7.         struct { _TX x,y; };         
  8.         _TX _m[2];     
  9.     };
  10. }
  11.  
  12. /// 3x3행렬 템플릿 구조체
  13. template <class _tx=mF32>
  14. struct mt_MATRIX9
  15. {     
  16.     union     
  17.     {         
  18.         struct 
  19.         {               
  20.             _tx m11,m12,m13;               
  21.             _tx m21,m22,m23;               
  22.             _tx m31,m32,m33;         
  23.         };         
  24.         _tx _m[9];     
  25.     };
  26. };
  27.  
  28. /// 3x3행렬식 구하기
  29. template <class _tx>
  30. mINLINE _tx mDeterminats(mIN const mt_MATRIX9<_tx>& _mx)
  31. {     
  32.     _tx ret=_mx.m11*_mx.m22*_mx.m33 -  _mx.m11*_mx.m23*_mx.m32-    _mx.m12*_mx.m21*_mx.m33+ _mx.m13*_mx.m21*_mx.m32+          _mx.m12*_mx.m23*_mx.m31- _mx.m13*_mx.m22*_mx.m31;     
  33.     return ret;
  34. }
  35.  
  36. /* @brief 2D 벡터 크기*/
  37. template <class _tx, int _type>
  38. mINLINE _tx mMagnitude(mIN const mt_POINT2<_tx,_type> &p)
  39. {     return (p.x*p.x+p.y*p.y); }
  40.  
  41. /** @brief 두 점간의 거리 */
  42. /** @return float형거리 */
  43. template <class _tx, int _type>
  44. mINLINE mF32 mDistancef(mIN const mt_POINT2<_tx,_type> &p1, mIN const  mt_POINT2<_tx,_type> &p2)
  45. {     
  46.     mF32 Magnitude=mMagnitude(p2-p1);     
  47.     return (mF32)sqrt(Magnitude);
  48. }
 
외접원의 중심 좌표구하기 (Language : cpp)
  1. template <class _tx, int _type>
  2. mINLINE mt_POINT2<_tx,_type> mCircumCenter(mIN const
  3. mt_POINT2<_tx,_type>& p1, mIN const mt_POINT2<_tx,_type>& p2,
  4. mIN const mt_POINT2<_tx,_type>& p3)
  5. {     
  6.     mt_POINT2<_tx,_type> ret;     
  7.     mt_MATRIX9<_tx> mxA={p1.x, p1.y, 1,
  8.                              p2.x, p2.y, 1,
  9.                              p3.x, p3.y, 1};
  10.  
  11.     _tx dA=mDeterminats(mxA);   
  12.     mt_MATRIX9<_tx> mxBx={p1.x*p1.x+p1.y*p1.y, p1.y, 1,
  13.                              p2.x*p2.x+p2.y*p2.y, p2.y, 1,
  14.                              p3.x*p3.x+p3.y*p3.y, p3.y, 1};
  15.     _tx bx=-mDeterminats(mxBx);   
  16.     mt_MATRIX9<_tx> mxBy={p1.x*p1.x+p1.y*p1.y, p1.x, 1,
  17.                              p2.x*p2.x+p2.y*p2.y, p2.x, 1,
  18.                              p3.x*p3.x+p3.y*p3.y, p3.x, 1};     
  19.     _tx by=mDeterminats(mxBy);
  20.     ret.x = -(bx/(2.*dA));   
  21.     ret.y = -(by/(2.*dA));   
  22.     return ret;
  23. }
 
외접원의 반지름 구하기 (Language : cpp)
  1. /// 2D 삼각형(Triangle)의 넓이
  2. template <class _tx, int _type>
  3. mINLINE  mF32 mSemiPerimeterf(mIN const mt_POINT2<_tx,_type>& p1,
  4. mIN const mt_POINT2<_tx,_type>& p2, mIN const mt_POINT2<_tx,_type>& p3)
  5. { 
  6.     // p1=A, p2=B, p3=C   
  7.     mF32 a=mDistancef(p2,p3);   
  8.     mF32 b=mDistancef(p1,p3);   
  9.     mF32 c=mDistancef(p1,p2);   
  10.     return (a+b+c)/2.f;
  11. }
  12.  
  13. /** * @brief 2D 삼각형(Triangle)의 외접원의 반지름 * @return float형 */
  14. template <class _tx, int _type> mINLINE mF32 mOutRadiusf(mIN
  15. const mt_POINT2<_tx,_type>& p1, mIN const mt_POINT2<_tx,_type>&
  16. p2,   mIN const mt_POINT2<_tx,_type>& p3)
  17. {   
  18.     // p1=A, p2=B, p3=C   
  19.     mF32 a=mDistancef(p2,p3);   
  20.     mF32 b=mDistancef(p1,p3);   
  21.     mF32 c=mDistancef(p1,p2);   
  22.     mF32 s=mSemiPerimeterf(p1,p2,p3);   
  23.     mF32 R = (a*b*c)/(4*sqrt(s*(s-a)*(s-b)*(s-c)));         return R;
  24. }

Posted by chungki

2007/03/23 22:20 2007/03/23 22:20
,
Response
No Trackback , No Comment
RSS :
http://www.chungki.net/tc/rss/response/243

« Previous : 1 : 2 : 3 : 4 : 5 : Next »

블로그 이미지

Nice !!!!!!!!

- chungki

Notices

Archives

Authors

  1. chungki

Calendar

«   2012/05   »
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Site Stats

Total hits:
73374
Today:
5
Yesterday:
20