728x90
반응형
#include <windows.h>
#include "vfw.h"
#pragma comment(lib, "vfw32.lib")
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
LRESULT CALLBACK FramInfo(HWND, LPVIDEOHDR);
HINSTANCE g_hInst;
HWND HWndMain;
LPCTSTR lpszClass=TEXT("WiseCat");
HWND vfw;
BITMAPINFO Bm;
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance
,LPSTR lpszCmdParam,int nCmdShow)
{
HWND hWnd;
MSG Message;
WNDCLASS WndClass;
g_hInst = hInstance;
WndClass.cbClsExtra=0;
WndClass.cbWndExtra=0;
WndClass.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);
WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
WndClass.hInstance=hInstance;
WndClass.lpfnWndProc=WndProc;
WndClass.lpszClassName=lpszClass;
WndClass.lpszMenuName=NULL;
WndClass.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&WndClass);
hWnd=CreateWindow( lpszClass
,lpszClass
,WS_OVERLAPPEDWINDOW
,CW_USEDEFAULT
,CW_USEDEFAULT
,CW_USEDEFAULT,CW_USEDEFAULT
,NULL
,(HMENU)NULL
,hInstance
,NULL);
ShowWindow(hWnd,nCmdShow);
while(GetMessage(&Message,NULL,0,0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return (int)Message.wParam;
}
HDC hdc;
LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
PAINTSTRUCT ps;
switch(iMessage)
{
case WM_CREATE:
HWndMain = hWnd;
vfw = capCreateCaptureWindow( TEXT("CAM")
,WS_CHILD | WS_VISIBLE
,0
,0
,400
,300
,hWnd
,NULL);
capDriverConnect(vfw,0);
capGetVideoFormat(vfw,&Bm,sizeof(Bm));
capSetCallbackOnFrame(vfw, FramInfo);
capPreviewRate(vfw, 1);
capPreview(vfw, FALSE);
return 0;
case WM_PAINT:
hdc = BeginPaint(hWnd,&ps);
EndPaint(hWnd,&ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}
LRESULT CALLBACK FramInfo(HWND hWnd, LPVIDEOHDR lpData)
{
static int iCntX;
static int iCntY;
static int Jump;
hdc = GetDC(HWndMain);
StretchDIBits(hdc , 0
, 0
, Bm.bmiHeader.biWidth
, Bm.bmiHeader.biHeight
, 0
, 0
, Bm.bmiHeader.biWidth
, Bm.bmiHeader.biHeight
, lpData->lpData
, &Bm
, DIB_RGB_COLORS
, SRCCOPY);
Jump= 0;
for(iCntY = 0; iCntY < Bm.bmiHeader.biHeight ; ++iCntY)
{
for(iCntX = 0; iCntX < Bm.bmiHeader.biWidth ; ++iCntX, Jump += 3 )
{
if(lpData->lpData[Jump + 2] > 100)
{
continue;
}
if(lpData->lpData[Jump + 1] > 100)
{
continue;
}
if(lpData->lpData[Jump + 0] > 50)
{
lpData->lpData[Jump] = 0; // Blue
lpData->lpData[Jump + 2] = 255; // Red
lpData->lpData[Jump + 1] = 0; // Green
}
}
}
StretchDIBits(hdc , Bm.bmiHeader.biWidth +20
, 0
, Bm.bmiHeader.biWidth
, Bm.bmiHeader.biHeight
, 0
, 0
, Bm.bmiHeader.biWidth
, Bm.bmiHeader.biHeight
, lpData->lpData
, &Bm
, DIB_RGB_COLORS
, SRCCOPY);
ReleaseDC(HWndMain, hdc);
return 0;
}
#include "vfw.h"
#pragma comment(lib, "vfw32.lib")
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
LRESULT CALLBACK FramInfo(HWND, LPVIDEOHDR);
HINSTANCE g_hInst;
HWND HWndMain;
LPCTSTR lpszClass=TEXT("WiseCat");
HWND vfw;
BITMAPINFO Bm;
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance
,LPSTR lpszCmdParam,int nCmdShow)
{
HWND hWnd;
MSG Message;
WNDCLASS WndClass;
g_hInst = hInstance;
WndClass.cbClsExtra=0;
WndClass.cbWndExtra=0;
WndClass.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);
WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
WndClass.hInstance=hInstance;
WndClass.lpfnWndProc=WndProc;
WndClass.lpszClassName=lpszClass;
WndClass.lpszMenuName=NULL;
WndClass.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&WndClass);
hWnd=CreateWindow( lpszClass
,lpszClass
,WS_OVERLAPPEDWINDOW
,CW_USEDEFAULT
,CW_USEDEFAULT
,CW_USEDEFAULT,CW_USEDEFAULT
,NULL
,(HMENU)NULL
,hInstance
,NULL);
ShowWindow(hWnd,nCmdShow);
while(GetMessage(&Message,NULL,0,0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return (int)Message.wParam;
}
HDC hdc;
LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
PAINTSTRUCT ps;
switch(iMessage)
{
case WM_CREATE:
HWndMain = hWnd;
vfw = capCreateCaptureWindow( TEXT("CAM")
,WS_CHILD | WS_VISIBLE
,0
,0
,400
,300
,hWnd
,NULL);
capDriverConnect(vfw,0);
capGetVideoFormat(vfw,&Bm,sizeof(Bm));
capSetCallbackOnFrame(vfw, FramInfo);
capPreviewRate(vfw, 1);
capPreview(vfw, FALSE);
return 0;
case WM_PAINT:
hdc = BeginPaint(hWnd,&ps);
EndPaint(hWnd,&ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}
LRESULT CALLBACK FramInfo(HWND hWnd, LPVIDEOHDR lpData)
{
static int iCntX;
static int iCntY;
static int Jump;
hdc = GetDC(HWndMain);
StretchDIBits(hdc , 0
, 0
, Bm.bmiHeader.biWidth
, Bm.bmiHeader.biHeight
, 0
, 0
, Bm.bmiHeader.biWidth
, Bm.bmiHeader.biHeight
, lpData->lpData
, &Bm
, DIB_RGB_COLORS
, SRCCOPY);
Jump= 0;
for(iCntY = 0; iCntY < Bm.bmiHeader.biHeight ; ++iCntY)
{
for(iCntX = 0; iCntX < Bm.bmiHeader.biWidth ; ++iCntX, Jump += 3 )
{
if(lpData->lpData[Jump + 2] > 100)
{
continue;
}
if(lpData->lpData[Jump + 1] > 100)
{
continue;
}
if(lpData->lpData[Jump + 0] > 50)
{
lpData->lpData[Jump] = 0; // Blue
lpData->lpData[Jump + 2] = 255; // Red
lpData->lpData[Jump + 1] = 0; // Green
}
}
}
StretchDIBits(hdc , Bm.bmiHeader.biWidth +20
, 0
, Bm.bmiHeader.biWidth
, Bm.bmiHeader.biHeight
, 0
, 0
, Bm.bmiHeader.biWidth
, Bm.bmiHeader.biHeight
, lpData->lpData
, &Bm
, DIB_RGB_COLORS
, SRCCOPY);
ReleaseDC(HWndMain, hdc);
return 0;
}
728x90
'기술자료 > JPEG 압축 영상' 카테고리의 다른 글
[JPEG]JPEG 포맷 (1) | 2009.08.20 |
---|---|
[JPEG] JPEG 압축 알고리즘의 분류 (1) | 2009.08.20 |
[클란심] 허프만 알고리즘 (3) | 2009.08.12 |
[JPEG Study] 제 2장 컴퓨터와 멀티미디어 환경 (3) | 2009.08.05 |
[SB]영상처리관련 (0) | 2009.08.05 |
[클란심] 데이터 압축이란? (5) | 2009.08.05 |
[JPEG Study] [Chap[1.5] 정보압축 방법] (3) | 2009.07.23 |