• Tistory
    • 태그
    • 위치로그
    • 방명록
    • 관리자
    • 글쓰기
Carousel 01
Carousel 02
Previous Next

Picture Control에 영상 출력하기.

Programming/Windows 2015. 5. 27. 22:02




예전에 리소스 등록하여 BMP 출력하는거 썼었네..


이번에는 IplImage 등의 구조체로 읽어들인 영상을 Picture Control에 출력하는 방법을 다룬다.


당장은 쓸 일 없지만 나중에 쓸라그럼 내머리가 기억을 못할테니..


적어놔야지..

//-----------------------------------------------------

// 사용할 영상

IplImage* tmp = cvLoadImage("경로\\SIMG_3380.jpg");

    

    CDC* pDC;

    CRect rect;

// m_stDisplay 는 picture control의 멤버변수명.

    pDC = m_stDisplay.GetDC();

    m_stDisplay.GetClientRect(&rect);



    BITMAPINFO bitmapInfo;

    bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);

    bitmapInfo.bmiHeader.biPlanes = 1;

    bitmapInfo.bmiHeader.biCompression = BI_RGB;

    bitmapInfo.bmiHeader.biXPelsPerMeter = 100;

    bitmapInfo.bmiHeader.biYPelsPerMeter = 100;

    bitmapInfo.bmiHeader.biClrUsed = 0;

    bitmapInfo.bmiHeader.biClrImportant = 0;

    bitmapInfo.bmiHeader.biSizeImage = 0;

    bitmapInfo.bmiHeader.biWidth = tmp->width;

    bitmapInfo.bmiHeader.biHeight = -tmp->height;

    IplImage* tempImage;

    if (tmp->nChannels == 3)

    {

        tempImage = (IplImage*)cvClone(tmp);

        bitmapInfo.bmiHeader.biBitCount = tempImage->depth * tempImage->nChannels;

    }

    else if (tmp->nChannels == 1)

    {

        tempImage = cvCreateImage(cvGetSize(tmp), IPL_DEPTH_8U, 3);

        cvCvtColor(tmp, tempImage, CV_GRAY2BGR);

        bitmapInfo.bmiHeader.biBitCount = tempImage->depth * tempImage->nChannels;

    }

    pDC->SetStretchBltMode(COLORONCOLOR);

    ::StretchDIBits(pDC->GetSafeHdc(), rect.left, rect.top, rect.right, rect.bottom,

        0, 0, tempImage->width, tempImage->height, tempImage->imageData, &bitmapInfo,

        DIB_RGB_COLORS, SRCCOPY);

    cvReleaseImage(&tempImage);


// release 잘해주기.

    ReleaseDC(pDC);


    cvReleaseImage(&tmp);

//-----------------------------------------------------


결과 :


아래처럼 Picture Control을 생성 해두고 

출력 하면 딱 사이즈 맞게 출력된다.


아래는 덤으로.. 테스트에 사용된 사진.


작년 제주도에서 찍은 사진. 나름 맘에들어. ㅋㅋ


저작자표시비영리

'Programming > Windows' 카테고리의 다른 글

taskkill 명령어를 이용하여 프로세스를 강제종료하자  (0) 2017.02.16
Picture Control에 영상 출력하기.  (0) 2015.05.27
CWnd <- -> HWND  (0) 2015.05.27
블로그 이미지

매직블럭

작은 지식들 그리고 기억 한조각

트랙백 0개, 댓글 0개가 달렸습니다

댓글을 달아 주세요

  • «
  • 1
  • 2
  • 3
  • »

카테고리

  • 살다보니.. (418)
    • 주절거림 (3)
    • 취미생활 (36)
      • 지식과 지혜 (3)
      • 풍경이 되어 (4)
      • Memories (17)
      • 엥겔지수를 높여라 (2)
    • mathematics (6)
      • Matrix Computation (2)
      • RandomProcesses (3)
    • English.. (8)
    • Programming (138)
      • C, C++, MFC (51)
      • C# (1)
      • OpenCV (17)
      • Python (51)
      • Git, Docker (3)
      • Matlab (4)
      • Windows (3)
      • Kinect V2 (2)
      • 기타 etc. (6)
    • 전공관련 (73)
      • Algorithm (6)
      • Deep Learning (49)
      • 실습 프로그램 (4)
      • 주워들은 용어정리 (8)
      • 기타 etc. (6)
    • Computer (104)
      • Utility (21)
      • Windows (24)
      • Ubuntu, Linux (55)
      • NAS (2)
      • Embedded, Mobile (2)
    • IT, Device (41)
      • 제품 사용기, 개봉기 (14)
      • 스마트 체험단 신청 (27)
    • Wish List (3)
    • TISTORY TIP (5)
    • 미분류. 수정중 (1)

태그목록

  • Convolutional Neural Networks
  • function
  • CStdioFile
  • 큐슈
  • 스마트체험단
  • Deep Learning
  • Computer Tip
  • 에누리닷컴
  • 오봉자싸롱
  • 갤럭시노트3
  • 매트랩
  • 딥러닝
  • ReadString
  • 칼로리 대폭발
  • 매트랩 함수
  • matlab
  • 일본
  • 크롬
  • utility
  • DSLR
  • matlab function
  • 후쿠오카
  • SVM
  • ColorMeRad
  • portugal
  • LIBSVM
  • random variable
  • review
  • DeepLearning
  • 포르투갈

달력

«   2022/08   »
일 월 화 수 목 금 토
  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      
08-14 12:41

LATEST FROM OUR BLOG

  • windows terminal(powershell⋯.
  • vscode terminal 에 conda를⋯.
  • vscode에 conda 가상환경을⋯.
  • vscode keymap을 변경하자.
  • 골뱅이 연산자의 의미 (행렬곱)..
  • 프린터 용지 부족 문제를 해⋯.
  • [MXNet] 데이터 리스트를 만⋯.
  • 예쁘게 출력하자 pprint - pr⋯.
  • 작업표시줄 미리보기를 리스⋯.
  • 이미지 실제 파일 포맷 확인하기.
RSS 구독하기

BLOG VISITORS

  • Total : 1,149,449
  • Today : 38
  • Yesterday : 164

Copyright © 2015 Socialdev. All Rights Reserved.

티스토리툴바