2004년 12월 4일 토요일

WMF(Windows Metafiles, wmf)

Reference site:
1. libwmf - http://wvware.sourceforge.net/caolan/index.html
2. http://netghost.narod.ru/gff/graphics/summary/micmeta.htm

Windows Metafiles(wmf) – 기본적으로 윈도우 메타 파일은 윈도우의 GDI(Windows Graphics Device Interface)의 호출한 기록을 의미한다. wmf 파일의 특징을 살펴보면 다음과 같습니다.

1. wmf 파일은 반대의 순서로 저장됩니다.

BOOL32 Rectangle
{
HDC32 hdc, //INT32가 32bit이나 이들의 크기는 16bit 단위로 저장됩니다.
INT32 left,
INT32 top,
INT32 right,
INT32 bottom
}

->저장순서 (32bit size of total record | 0x041B | bottom | right | top | left)
레코드는 Microsoft Windows Graphics Device Interface(GDI)의 function 호출을 바이너리로 인코딩 합니다.


2. 파일의 세부구조(File detail – 레퍼런스 자료들을 합쳤다.)

 1) header
typedef struct _WindowsMetaHeader
{
WORD FileType;
//1=memory, 2=disk, metafile의 위치(location)을 가리킨다.

WORD HeaderSize;
//Size of metafile header in WORDS = always 9

WORD Version;
//Version of Microsoft Windows used 값은 항상 hexadecimal foramt으로 저장
//Windows에 따라 달라지는 값으로 Windows3.0이면 300h를 갖습니다.


DWORD FileSize;
//Total size of the metafile in 16-bit WORDs

WORD NumOfObjects;
//Number of objects in the file

DWORD MaxRecordSize
//The size of largest record in the metafile in WORDs

WORD NoParameters
//Not used, always 0
}


2) 각 레코드의 기본 구조

typedef struct _WindowsMetaRecord
{
DWORD Size;
//Total size of the record in WORDs, including the Size field itself,
//minimum possible size = 3
WORD Fucntion;
//GDI number of the fuction number which defined in WINDOW.H
WORD Parameters[];
//Parameter is an array of the parameters used by the funciton.
//The parameters used by function are stored in the reverse order.
}WMFRecord;


3) 해당 record가 읽히는 순서대로 fuction이 불려집니다. 마지막 record로는 항상 function number of zero를 가지고 있으며 record data의 종료를 의미합니다. 대부분의 wmf 파일 포맷이 동일하지만 일부분은 다릅니다. 기본 record format을 사용하는 GDI method는 다음과 같습니다.



4)다음은 data format에서 data array보다 parameters field를 사용하는 메소드들입니다. 내부 구조는 Microsoft Windows Programmer's Reference Library를 참고하시기 바랍니다.




5) Microsoft Windows 3.0과는 달리 parameter가 변경되거나 수정된 GDI function들 입니다.




모든 GDI function들이 metafile에 포함될 수 있는 것은 아닙니다. 그들의 첫 번째 파라미터로서 device context를 다루는 경우만 유효합니다.


3. Porting WMF Files between applications
메타파일에는 22-byte header를 붙입니다. 이 헤더는 메타파일의 헤더 안에서는 발견되지 않는 정보들을 가지고 있습니다. 그러나 애플리케이션 사이에서 메타파일을 옮기는데 필요한 정보들입니다.

typedef struct _WmfSpecialHeader
{
DWORD Key;
//key는 특별한 헤더의 존재를 알리는 identification value로서 항상
//9AC6CDD7h의 값을 갖습니다.


WORD Handle;
//Handle은 사용되지 않으며 항상 0의 값을 갖는다.

SHORT Left;
SHORT Top;
SHORT Right;
SHORT Bottom;
//이미지의 upper-left와 lower-right 좌표를 나타냅니다.
//이들은 twips로 측정되며, 이 네 개의 점은 RECT 구조체의 필드 값과 일치합니다.


WORD Inch;
//이미지를 나타내는데 사용되는 twips 단위로서
//이미지의 스케일을 변경되는데 사용됩니다.
//720의 값은 보통 크기의 두 배를 의미하며 360은 네 배를,
//2880은 1/2로 축소, 1440은 1:1을 의미합니다.

DWORD Reserved;
//사용되지 않으며 항상 0으로 설정된다.

WORD Checksum;
//Checksum contains a checksum value
//for the previous 10 WORDs in the header,
//calculated by XORing each WORD value to 0

}


※ twips는 모든 디스플레이 시스템에서 동일한 스크린 요소의 비율을 확인하기 위한 스크린 독립적인 유닛을 말한다. twip은 인치의 1/1440으로 정의된다.
※ pixel은 picture element를 기준으로 하는 스크린 의존적인 유닛으로 스크린상에서 그래픽으로 표현되는 가장 작은 수단인 dot를 말한다.

댓글 2개:

  1. 어렵다. 눈 아프다.

    이런거 안보고 편히 살 수 있으면 얼마나 좋을까.

    연수 들어가면 6주간의 주입식 교육의 압쀍이 쀍!

    답글삭제
  2. 가냐? 가는구나~



    좋겠다~~~ 가기 전에 얼굴이나 보고 가라~

    답글삭제