블로그 이미지
훅크선장

카테고리

분류 전체보기 (361)
사진이야기 (23)
펭귄컴퓨팅 (120)
컴퓨터보안 (84)
절름발이 프로그래머 (59)
하드웨어개조 (23)
멀알려줄까 (35)
홈베이킹&홈쿠킹 (2)
잡다한것들 (15)
Total
Today
Yesterday

달력

« » 2024.4
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

공지사항

태그목록

최근에 올라온 글

http://www.delphipraxis.net/147190-how-work-wic.html 를 참고하였습니다.

WIC 라는 개념이 Delphi 2010부터 지원됩니다. 여러 종류의 그래픽 파일들의 자유로운 읽기, 쓰기, 변환이 지원된다고 합니다. RAW 파일까지도 자유롭게 다룰 수 있다고 합니다.

아래와 같은 소스를 만들어서 테스트해보시면 알 수 있습니다. 중요한 점은 Wincodec 을 uses 구문에 추가하는 것입니다.
-------------------------------------------------------------------------------------------------------------
unit MainUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Wincodec;

type
  TForm1 = class(TForm)
    OpenPictureDialog: TOpenDialog;
    btnOpen: TButton;
    edtIamgeFilePath: TEdit;
    Image: TImage;
    procedure btnOpenClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

// Function() to test if this engine working correctly
function WICImageFormatDescription(const WIC: TWICImage): string;
begin
  Result := '';

  case WIC.ImageFormat of
    wifBmp: Result := 'Bitmap';
    wifPng: Result := 'PNG';
    wifJpeg: Result := 'JPEG';
    wifGif: Result := 'GIF';
    wifTiff: Result := 'TIFF';
    wifWMPhoto: Result := 'JPEG XR';
    wifOther:
    begin
      if GUIDToString(WIC.EncoderContainerFormat) = GUIDToString(GUID_ContainerFormatIco) then
        Result := 'Icon'
      else
        Result := 'other'
      ;
    end;
  end;
end;


procedure TForm1.btnOpenClick(Sender: TObject);
var
  WIC: TWICImage;
begin
  WIC := TWICImage.Create;
  try
    if OpenPictureDialog.Execute then
    begin
      edtIamgeFilePath.Text := OpenPictureDialog.FileName;
      WIC.LoadFromFile(OpenPictureDialog.FileName);
      Image.Picture.Assign(WIC);
      ShowMessage(WICImageFormatDescription(WIC));
      WIC.ImageFormat := wifWMPhoto;
      WIC.SaveToFile('output.wdp');
    end;
  finally
    WIC.Free;
  end;
end;

end.
Posted by 훅크선장
, |