마음의 안정을 찾기 위하여 - 투명한 아이콘 만들기 (PNG Image To Icon Convert)
2275995
24
494
관리자새글쓰기
태그위치로그방명록
별일없다의 생각
dawnsea's me2day/2010
색상(RGB)코드 추출기(Color...
Connection Generator/2010
최승호PD, '4대강 거짓말 검...
Green Monkey**/2010
Syng의 생각
syng's me2DAY/2010
천재 작곡가 윤일상이 기획,...
엘븐킹's Digital Factory/2010
투명한 아이콘 만들기 (PNG Image To Icon Convert)
Delphi/Image Processing | 2008/07/17 14:22

Required : PNGDelphi Component

function PNGtoIcon(const APNG : TPNGObject; 
                      ACursor : Boolean = false; 
                      AHotSpotX : Integer = 0; 
                      AHotSpotY : Integer = 0) : HICON; 
var 
  Width, Height : Integer; 
  BitmapHeader  : PBitmapV5Header; 
  hNewBitmap, 
  hMonoBitmap   : HBITMAP; 
  Bits          : Pointer; 
  x, 
  y             : Integer; 
  DC            : HDC; 
  IconInfo      : _ICONINFO; 
  Pixel         : ^Integer; 
  ScanLine      : PRGBTriple; 
  AlphaScanline : pByteArray; 
begin 
  Width := APNG.Width; 
  Height := APNG.Height; 
  New(BitmapHeader); 
  BitmapHeader.bV5Size := sizeof(BITMAPV5HEADER); 
  BitmapHeader.bV5Width := Width; 
  BitmapHeader.bV5Height := -Height; 
  BitmapHeader.bV5Planes := 1; 
  BitmapHeader.bV5BitCount := 32; 
  BitmapHeader.bV5Compression := BI_BITFIELDS; 
  BitmapHeader.bV5RedMask := $00FF0000; 
  BitmapHeader.bV5GreenMask := $0000FF00; 
  BitmapHeader.bV5BlueMask := $000000FF; 
  BitmapHeader.bV5AlphaMask := $FF000000; 

  DC := GetDC(0); 
  hNewBitmap := CreateDIBSection( DC, 
                                PBitmapInfo(BitmapHeader)^, 
                                DIB_RGB_COLORS,
                                Bits,
                                0,
                                0);
  Dispose(BitmapHeader);
  ReleaseDC(0,dc);
  hMonoBitmap:=CreateBitmap(Width,Height,1,1,nil); 
  Pixel := Bits; 
  for y := 0 to Height-1 do 
  begin 
    ScanLine := APNG.Scanline[y]; 
    AlphaScanline := APNG.AlphaScanline[y]; 
    for x := 0 to Width - 1 do 
    begin 
      Pixel^ := AlphaScanLine[x];
      Pixel^ := Pixel^ shl 8; 
      Inc(Pixel^, Scanline^.rgbtRed);
      Pixel^ := Pixel^ shl 8; 
      Inc(Pixel^, Scanline^.rgbtGreen);
      Pixel^ := Pixel^ shl 8; 
      Inc(Pixel^, Scanline^.rgbtBlue);
      Inc(Pixel); 
      Inc(ScanLine); 
    end; 
  end; 
  IconInfo.fIcon := not ACursor; 
  if ACursor then 
  begin 
    IconInfo.xHotspot := AHotSpotX; 
    IconInfo.yHotspot := AHotSpotY; 
  end; 
  IconInfo.hbmMask := hMonoBitmap; 
  IconInfo.hbmColor := hNewBitmap; 
  Result := CreateIconIndirect(IconInfo); 
  DeleteObject(hNewBitmap); 
  DeleteObject(hMonoBitmap); 
end;


관련글 : MSDN - How To Create an Alpha Blended Cursor or Icon in Windows XP

2008/07/17 14:22 2008/07/17 14:22
Article tag list Go to top
View Comment 0
Trackback URL :: 이 글에는 트랙백을 보낼 수 없습니다
 
 
 
 
: [1] ... [542][543][544][545][546][547][548][549][550] ... [1317] :
«   2024/04   »
  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        
전체 (1317)
출판 준비 (0)
My-Pro... (41)
사는 ... (933)
블로그... (22)
My Lib... (32)
게임 ... (23)
개발관... (3)
Smart ... (1)
Delphi (93)
C Builder (0)
Object... (0)
VC, MF... (10)
Window... (1)
Open API (3)
Visual... (0)
Java, JSP (2)
ASP.NET (0)
PHP (5)
Database (12)
리눅스 (29)
Windows (25)
Device... (1)
Embedded (1)
게임 ... (0)
Web Se... (2)
Web, S... (21)
잡다한... (6)
프로젝트 (0)
Personal (0)
대통령... (13)
Link (2)