SDC C-Project CF Review 프로그램
LYW
2021-09-27 b9b6752e83c701cc67241923d2b74dc3a963d243
ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.cpp
@@ -121,6 +121,7 @@
   ON_BN_CLICKED(IDC_CHK_REVIEW_DEFECT, &CReveiwHistoryDlg::OnClickedChkReviewDefect)
   ON_BN_CLICKED(IDC_CHK_SINGLE, &CReveiwHistoryDlg::OnClickedChkSingle)
   ON_EN_CHANGE(IDC_EDIT_FILE_COUNT, &CReveiwHistoryDlg::OnChangeEditFileCount)
   ON_WM_KEYDOWN()
END_MESSAGE_MAP()
// CReveiwHistoryDlg 메시지 처리기
@@ -279,7 +280,15 @@
//          // 그림을 Picture Control 크기로 화면에 출력한다.
//          m_ReviewImage.Draw(dc, m_picture_rect);
//       }
      if (!m_DefectImage.IsNull())
      //LYW 20210825 #3486 ADD START
      if (!m_DefectRotateImage.IsNull())
      {
         dc.SetStretchBltMode(COLORONCOLOR);
         // 그림을 Picture Control 크기로 화면에 출력한다.
         m_DefectRotateImage.Draw(dc, m_picture_rect2);
      }
      //LYW 20210825 #3486 ADD END
      else if (!m_DefectImage.IsNull())
      {
         dc.SetStretchBltMode(COLORONCOLOR);
         // 그림을 Picture Control 크기로 화면에 출력한다.
@@ -730,7 +739,7 @@
         return TRUE;
      }
      else if (NM_CLICK == pDispInfo->hdr.code)
      else if (NM_CLICK == pDispInfo->hdr.code || LVN_ITEMCHANGING == pDispInfo->hdr.code)
      {
         if (pDispInfo->item.row == 0)
         {
@@ -856,7 +865,7 @@
         return TRUE;
      }
      else if (NM_CLICK == pDispInfo->hdr.code)
      else if (NM_CLICK == pDispInfo->hdr.code || LVN_ITEMCHANGING == pDispInfo->hdr.code)
      {
         if (pDispInfo->item.row == 0)
         {
@@ -1968,6 +1977,9 @@
   m_DefectImage.Destroy();
   m_ReviewImage.Destroy();
   //LYW 20210825 #3486 ADD START
   m_DefectRotateImage.Destroy();
   //LYW 20210825 #3486 ADD END
   m_AlignFirst.Destroy();
   m_AlignSecend.Destroy();
@@ -2055,7 +2067,7 @@
   DeftectPath.Format(_T("%s\\%s\\%s"), strReviewPath, strReviewImagePath, strReviewImageName);
   //DeftectPath2.Format(_T("%s\\%s"), strInspectorPath, strInspectorName);
   if (strInspectorName == "*" || strInspectorName == "**" || strInspectorName == "***") strInspectorName = "";
   DeftectPath2.Format(_T("%s\\%s\\%s"), strInspectorPath, pImageInfo->m_strGlassID, strReviewImageName);
   DeftectPath2.Format(_T("%s\\%s\\%s"), strInspectorPath, pImageInfo->m_strGlassID, strInspectorName);
   AlignPath.Format(_T("%s\\%s\\%s"), strAlignPath, pImageInfo->m_strGlassID, strAlignName);
   AlignPath2.Format(_T("%s\\%s\\%s"), strAlignPath, pImageInfo->m_strGlassID, strAlignName2);
@@ -2096,13 +2108,21 @@
   if (CFile::GetStatus(DeftectPath2, FileOn) && strInspectorName != "") //파일이 있을 때
   {
      m_DefectImage.Load(DeftectPath2);
      //LYW 20210825 #3486 ADD START
      m_DefectRotateImage.Create(m_DefectImage.GetWidth(), m_DefectImage.GetHeight(), m_DefectImage.GetBPP(), 0);
      ImageRotate(m_DefectImage, m_DefectRotateImage);
      //LYW 20210825 #3486 ADD END
      HBITMAP hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), DeftectPath2,
         IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
      InvalidateRect(m_picture_rect2, FALSE);
      dc.SetStretchBltMode(COLORONCOLOR);
      m_DefectImage.Draw(dc, m_picture_rect2);
      //LYW 20210825 #3486 MOD START
      m_DefectRotateImage.Draw(dc, m_picture_rect2);
      //LYW 20210825 #3486 MOD END
      //original
      //m_DefectImage.Draw(dc, m_picture_rect2);
   }
   else
   {
@@ -2490,6 +2510,9 @@
//   m_ReviewImage.Destroy();
   m_DefectImage.Destroy();
   //LYW 20210825 #3486 ADD START
   m_DefectRotateImage.Destroy();
   //LYW 20210825 #3486 ADD END
   m_AlignFirst.Destroy();
   m_AlignSecend.Destroy();
@@ -2526,6 +2549,48 @@
   m_AlignFirst.Draw(dc, m_Align_rect);
   m_AlignSecend.Draw(dc, m_Align_rect2);
}
//LYW 20210825 #3486 ADD START
void CReveiwHistoryDlg::ImageRotate(CImage & SrcImage, CImage & DstImage, double degree/* = 180.0 */)
{
   int Height = SrcImage.GetHeight(); // 세로 길이 저장
   int Width = SrcImage.GetWidth(); // 가로 길이 저장
   int new_x, new_y;
   int R, G, B;
   int center_x = (SrcImage.GetWidth() / 2); // 회전 중심점
   int center_y = (SrcImage.GetHeight() / 2); // 회전 중심점
   double seta = 3.14 / (180.0 / degree); // 라디안
   double CosSeta = cos(seta);
   double SinSeta = sin(seta);
   for (int y = 0; y < Height; y++)
   {
      for (int x = 0; x < Width; x++)
      {
         new_x = (int)((x - center_x) * CosSeta - (y - center_y) * SinSeta + center_x);
         new_y = (int)((x - center_x) * SinSeta + (y - center_y) * CosSeta + center_y);
         if ((new_x < 0) || (new_x > Width) || (new_y < 0) || (new_y > Height))
            //이미지 범위를 벗어나면 0 값
         {
            R = 0;
            G = 0;
            B = 0;
         }
         else
         {
            R = GetRValue(SrcImage.GetPixel(new_x, new_y));
            G = GetGValue(SrcImage.GetPixel(new_x, new_y));
            B = GetBValue(SrcImage.GetPixel(new_x, new_y));
         }
         DstImage.SetPixel((int)x, (int)y, RGB(R, G, B));
         new_x = 0; new_y = 0;
      }
   }
}
//LYW 20210825 #3486 ADD END
void CReveiwHistoryDlg::OnChangeEditFileCount()
{
@@ -3764,3 +3829,11 @@
   }
   m_Formation.m_vecHeaderTemp.clear();
}
void CReveiwHistoryDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
   // TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
   CDialogEx::OnKeyDown(nChar, nRepCnt, nFlags);
}