Blog
Tag
Keylog
Guest Book
English
그레이스케일 아이콘 만들기
:: 2006/03/10 18:40
/
코드/win32
코드 프로젝트 받은 소스 분석하다 잼써서 올려봅니당...
// This function creates a grayscale icon starting from a given icon. // The resulting icon will have the same size of the original one. // // Parameters: // [IN] hIcon // Handle to the original icon. // // Return value: // If the function succeeds, the return value is the handle // to the newly created grayscale icon. // If the function fails, the return value is NULL. // // Updates: // 26/Nov/2002 Restored 1 BitBlt operation // 03/May/2002 Removed dependancy from m_hWnd // Removed 1 BitBlt operation // HICON CButtonST::CreateGrayscaleIcon(HICON hIcon) { HICON hGrayIcon = NULL; HDC hMainDC = NULL, hMemDC1 = NULL, hMemDC2 = NULL; BITMAP bmp; HBITMAP hOldBmp1 = NULL, hOldBmp2 = NULL; ICONINFO csII, csGrayII; BOOL bRetValue = FALSE; bRetValue = ::GetIconInfo(hIcon, &csII); if (bRetValue == FALSE) return NULL; hMainDC = ::GetDC(NULL); hMemDC1 = ::CreateCompatibleDC(hMainDC); hMemDC2 = ::CreateCompatibleDC(hMainDC); if (hMainDC == NULL || hMemDC1 == NULL || hMemDC2 == NULL) return NULL; if (::GetObject(csII.hbmColor, sizeof(BITMAP), &bmp)) { DWORD dwWidth = csII.xHotspot*2; DWORD dwHeight = csII.yHotspot*2; csGrayII.hbmColor = ::CreateBitmap(dwWidth , dwHeight , bmp.bmPlanes , bmp.bmBitsPixel , NULL); if (csGrayII.hbmColor) { hOldBmp1 = (HBITMAP)::SelectObject(hMemDC1, csII.hbmColor); hOldBmp2 = (HBITMAP)::SelectObject(hMemDC2, csGrayII.hbmColor); DWORD dwLoopY = 0, dwLoopX = 0; COLORREF crPixel = 0; BYTE byNewPixel = 0; for (dwLoopY = 0; dwLoopY < dwHeight; dwLoopY++) { for (dwLoopX = 0; dwLoopX < dwWidth; dwLoopX++) { crPixel = ::GetPixel(hMemDC1, dwLoopX, dwLoopY); byNewPixel = (BYTE)((GetRValue(crPixel) * 0.299) + (GetGValue(crPixel) * 0.587) + (GetBValue(crPixel) * 0.114)); if (crPixel) ::SetPixel(hMemDC2 , dwLoopX , dwLoopY , RGB(byNewPixel, byNewPixel, byNewPixel)); else ::SetPixel(hMemDC2, dwLoopX, dwLoopY, crPixel); } // for } // for ::SelectObject(hMemDC1, hOldBmp1); ::SelectObject(hMemDC2, hOldBmp2); csGrayII.hbmMask = csII.hbmMask; csGrayII.fIcon = TRUE; hGrayIcon = ::CreateIconIndirect(&csGrayII); } // if ::DeleteObject(csGrayII.hbmColor); //::DeleteObject(csGrayII.hbmMask); } // if ::DeleteObject(csII.hbmColor); ::DeleteObject(csII.hbmMask); ::DeleteDC(hMemDC1); ::DeleteDC(hMemDC2); ::ReleaseDC(NULL, hMainDC); return hGrayIcon; } // End of CreateGrayscaleIcon
스폰서
글타래
관련 글
Draw3dRect의 정체
(2876)
최근 글
블로그 옮겼습니다.
(6892)
노무현 전 대통령님의 서거
(6141)
정보처리기사
(5413)
2주간 인기 글
2주간 인기글이 없습니다.
gdi
,
그레이스케일
,
아이콘
2218
명이 보았고,
댓글이 없습니다.
받은 트랙백이 없고, ...
Trackback Address ::
http://jiniya.net/tt/trackback/22
Name
Password
Homepage
Secret
< PREV
|
1
|
...
511
|
512
|
513
|
514
|
515
|
516
|
517
|
518
|
519
|
...
606
|
NEXT >
Informed
CodeWiz Profile
마이크로소프트웨어
테크박스
Cool Stuff
질문과 답변들
베스트 커멘터
Category
전체
(606)
종이
(266)
양피지
(76)
코드
(129)
win32
(44)
C/C++
(12)
레포트
(18)
기타
(4)
마이크로소프트웨어
(31)
패치
(15)
비스타
(2)
체스
(17)
키보드
(77)
스피커
(18)
책갈피
(58)
팝콘
(40)
Photo Log
Tags
버전
The Old New Thing
그 해 여름
The art of Computer Virus Research and Defense
레이몬드 첸
파일
레이몬드 첸의 윈도우 개발 282 스토리
애드센스
Win32
그레이스케일
시골의사의 부사경제학
괴짜 경제학
MSDN
후킹
역공학
제거
추천
원고
맑고 향기롭게
윈도우
Recent Entries
블로그 옮겼습니다.
노무현 전 대통령님의 서거를..
(1)
정보처리기사
(5)
철권, 통발러브님 좀 짱인듯...
(2)
코딩, 코딩, 코딩, 그리고 코..
(6)
Recent Comments
그것은 당신이 플러그인 잘 작동..
02/09 - ipad case
I clearly think that the answe..
02/01 - Locksmith Columbus OH
성지순례 다녀갑니다
01/02 - 성지순례
좋은자료내요 ㅎ 잘보고 갑니다..
01/01 - 굴러가는
"qformat.dll" 을 Notepad++ 의..
2011 - 세벌식최종 자판 사용자.
Recent Trackbacks
Writing Solid Code(버그 안녕)..
김재호의 디지털보단 아날로그
시스의 생각
oooooxo's me2day
CRT 이야기 [펌]
yamoe.tistory.com
윈도우 개발 282 스토리 -레이몬..
김재호의 디지털보단 아날로그
PEview
휘바골드's Blog
Calendar
«
2012/02
»
일
월
화
수
목
금
토
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
Archive
2010/07
2009/05
2009/03
2009/02
2009/01
2008/12
2008/11
2008/10
2008/09
2008/08
2008/07
2008/06
2008/05
2008/02
2008/01
2007/12
2007/11
2007/10
2007/09
2007/08
Link Site
KAISTIZEN
Mirjini
SNAIPER의 조그마한 블로그
VC 뉴스그룹
Welcome to conv2.blog - Conv..
Wiziple Blog
zoops 이야기
[크리™]'s big book of..
…─━ INSIDE ━─…, 미래가..
내 성격 100% 활용하기 -上-
유유자적을 꿈꾸며...
정성태님 홈페이지
질럿님
Total : 1058385
Today :
502
Yesterday : 608