Модераторы: Poseidon, Snowy, bems, MetalFan
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> как вынуть EMF файл из SPL файла, формат SPL файла 
:(
    Опции темы
YuriL
Дата 6.9.2005, 11:15 (ссылка)    |    (голосов: 0) Загрузка ... Загрузка ... Быстрая цитата Цитата


Unregistered











Привет Всем,
прошу вашей помощи в прочтении файла spl

Описание spl формата файла, которое мне удалось найти в сети
прилагаю (не хочу переводить с английского во избежание искажений оригинального текста)


Please note that this format is not officially documented and as such may change in future versions of the operating systems.
Additionally there may be errors or ommissions which are due entirely to myself



Overview



The EMF spool file is a collection of special records which define the output to be printed in a set of graphics primitives
which are broadly speaking an enhanced set of the EMF graphics records that windows developers are familiar with.
These are wrapped in additional layer of records to describe the pages and printer settings information.



The record types are:-

Private Enum SpoolerRecordTypes
SRT_EOF = &H0 ' // int32 zero
SRT_RESERVED_1 = &H1 '* 1 */
SRT_FONTDATA = &H2 ' 2 Font Data */
SRT_DEVMODE = &H3 ' 3 DevMode */
SRT_FONT2 = &H4 '4 Font Data */
SRT_RESERVED_5 = &H5 ' 5 */
SRT_FONT_MM = &H6 ' 6 Font Data (Multiple Master) */
SRT_FONT_SUB1 = &H7 ' 7 Font Data (SubsetFont 1) */
SRT_FONT_SUB2 = &H8 ' 8 Font Data (SubsetFont 2)
SRT_RESERVED_9 = &H9
SRT_UNKNOWN = &H10 ' // int unknown...
SRT_RESERVED_A = &HA
SRT_RESERVED_B = &HB
SRT_PAGE = &HC ' 12 Enhanced Meta File (EMF) */
SRT_EOPAGE1 = &HD ' 13 EndOfPage */
SRT_EOPAGE2 = &HE ' 14 EndOfPage */
SRT_EXT_FONT = &HF ' 15 Ext Font Data */
SRT_EXT_FONT2 = &H10 ' 16 Ext Font Data */
SRT_EXT_FONT_MM = &H11 ' 17 Ext Font Data (Multiple Master)
SRT_EXT_FONT_SUB1 = &H12 ' 18 Ext Font Data (SubsetFont 1) */
SRT_EXT_FONT_SUB2 = &H13 '* 19 Ext Font Data (SubsetFont 2) */
SRT_EXT_PAGE = &H14 ' 20 Enhanced Meta File?
SRT_JOB_INFO = &H10000 ' // int length, wchar jobDescription
End Enum

And each record type is followed by a 32 bit unsigned integer which is the size (in bytes) of the record.
This allows you to skip forward over any records that are not of use to you.
The interesting records of this lot are:




SRT_EOF - This record type indicates that you have reached the end of the spool file.
This may not be the actual end as some extra font dat amay be stored after this and referenced in an SRT_FONT type record.

SRT_DEVMODE - This record type has a DEVMODE structure following it.
This holds the details such as the paper size, device name, printer resolution etc. that apply to the print job.
It is possible to have more than one SRT_DEVMODE record in a spool file,
for example if the print job has some pages in portrait and others in landscape.

SRT_PAGE and SRT_EXT_PAGE - This record contains a standard EMF record that describes the graphical content of the printed page.
This starts with a EMFMETAHEADER record followed by one or more standard EMF graphics records
(EMFEXTTEXTOUTW, EMFELLIPSE etc.)


Uses



There are two uses for this information.
The first is to provide the capability to view spoolfiles on screen before they print
(you find each SRT_PAGE or SRT_EXTPAGE and convert it to a system.drawing.image)
and the other is to parse the file to get the true page count.

и более официальное описание

SPL Spoolfile Format
Terms of Use
Copyright A© 2004 by Christoph Lindemann. All rights reserved.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License,
Version 1.2 or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled "GNU Free Documentation License".

Comments
If you have any comments or further information on the SHD or SPL file format,
please feel free to contact me. [email protected]

History:
24-03-2004A A Initial Document
A A Christoph Lindemann, [email protected]

24-03-2004A A Release to public
A A Christoph Lindemann, [email protected]

10-06-2004A Added SPL_SMR_PADDING
A A Thanks to Fabian Franz

11-06-2004A CORRECTED FAULTY INFORMATIONS
A A Christoph Lindemann, [email protected]

14-06-2004A Added some text explaining the format.
A A Christoph Lindemann, [email protected]

19-05-2005A Corrected typos in SMREXT definition
A A Thanks to Peter Wasser

Introduction
The windows SPL files can include RAW data or EMF.
This document includes documentation for the EMF-SPL file format.


RAW SPL
In the case of RAW data, the content of the file is exactly the same as the data send to the printer.

EMF SPL
EMF stands for Enhanced Metafile. You can find information on standard EMF in the Windows Platform SDK.

Basically the SPL files consist of one or more standardA EMF files, surrounded by some extra records.
The EMF SPL files contain a special version of EMF ,
not compatible with standard EMF,
although most of the records are the same.

SPL_HEADER

SMR_PAGE_EMF/WMF
SMR_OFFS_FONT
SMR_OFFS_FONT
SMR_EO_PAGE

SMR_PAGE_EMF/WMF
SMR_DEVMODE
SMR_OFFS_FONT
SMR_OFFS_FONT
SMR_OFFS_FONT
SMR_EO_PAGE

Header

The SPL files always start with the SPL_HEADER, this record differs in the way,
that the specified recordsize includes both header and data of the SPL header.

Base record structure

TheA records following the SPL_HEADER, always start with (include) the SMR base record.
The nSize member specifies the size of the following data,
including the size of the remaining header members and the data. nSize = (RECORDSIZE - sizeof(SMR)).
So the SMR_EO_PAGE.nSize member would be = 8, as the complete record is 16 bytes (SMR + 8)

Page

Every page contained in the file consists of at least one SMR_PAGE_EMF andA one SMR_EO_PAGE record.
The SMR_PAGE_EMF contains the EMF data for the page.

Between these 2 records, every page can include some additional records like DEVMODE and font data for the page.

EOF End of File

SPL files can also include anA SMR_PAGE_EMFA record specifying a length of 0.
This record indicates the end of file.
The following data should not be considered valid.

DataA Definition
Код

//Spool Metafile constants
#define SPLMETA_SIGNATURE 0x00010000 //Version 1.0 

// Spool Metafile record types
#define SRT_RESERVED_1    0x00000001 /*  1                                */
#define SRT_FONT1         0x00000002 /*  2 Font Data                      */
#define SRT_DEVMODE       0x00000003 /*  3 DevMode                        */
#define SRT_FONT2         0x00000004 /*  4 Font Data                      */
#define SRT_RESERVED_5    0x00000005 /*  5                                */
#define SRT_FONT_MM       0x00000006 /*  6 Font Data (Multiple Master)    */
#define SRT_FONT_SUB1     0x00000007 /*  7 Font Data (SubsetFont 1)       */
#define SRT_FONT_SUB2     0x00000008 /*  8 Font Data (SubsetFont 2)       */
#define SRT_RESERVED_9    0x00000009 /*  9                                */
#define SRT_RESERVED_A    0x0000000A /* 10                                */ 
#define SRT_RESERVED_B    0x0000000B /* 11                                */
#define SRT_PAGE          0x0000000C /* 12 Enhanced Meta File (EMF)       */ 
#define SRT_EOPAGE1       0x0000000D /* 13 EndOfPage                      */
#define SRT_EOPAGE2       0x0000000E /* 14 EndOfPage                      */
#define SRT_EXT_FONT      0x0000000F /* 15 Ext Font Data                  */
#define SRT_EXT_FONT2     0x00000010 /* 16 Ext Font Data                  */
#define SRT_EXT_FONT_MM   0x00000011 /* 17 Ext Font Data (Multiple Master)*/
#define SRT_EXT_FONT_SUB1 0x00000012 /* 18 Ext Font Data (SubsetFont 1)   */
#define SRT_EXT_FONT_SUB2 0x00000013 /* 19 Ext Font Data (SubsetFont 2)   */
#define SRT_EXT_PAGE      0x00000014 /* 20 Enhanced Meta File?            */

///////////////////////////////////////////////////////////////
// SPL_HEADER
///////////////////////////////////////////////////////////////
//
// SPL file header for EMFSPL files
//
typedef struct tagSPLHEADER { 
    DWORD SIGNATURE; 
    DWORD nSize;            // record size INCLUDING header 
    DWORD offDocumentName;  // offset of Job Title from start 
    DWORD offPort;          // offset of portname from start
    BYTE HeaderData[]; 
} SPL_HEADER, *PSPL_HEADER;

///////////////////////////////////////////////////////////////
// SMR - Base record
///////////////////////////////////////////////////////////////
//
// Base record type for the Spool Metafile.
//
typedef struct tagSMR{ 
    DWORD iType; // Spool metafile record type 
    DWORD nSize; // length of the following data 
                 // NOT INCLUDING this header 
} SMR, *PSMR;

///////////////////////////////////////////////////////////////
// SMREXT - Extended record
///////////////////////////////////////////////////////////////
//
// Contains neg. distance to start of Data
//
typedef struct tagSMREXT{ 
    SMR smr; 
    DWORD DistanceLow; 
    DWORD DistanceHigh;
} SMREXT, *PSMREXT;

///////////////////////////////////////////////////////////////
// SMR_PAGE - EMF/Page data
///////////////////////////////////////////////////////////////
//
// EMF/Page data
//
typedef struct tagSMRPAGE{ 
    SMR smr; 
    BYTE EMFData[];
} SMR_PAGE, *PSMR_PAGE;

///////////////////////////////////////////////////////////////
// SMR_DEVMODE - DEVMODE data
///////////////////////////////////////////////////////////////
//
// DEVMODE data
//
typedef struct tagSMRDEVMODE{ 
    SMR smr; 
    BYTE DEVMODEData[];
} SMR_DEVMODE, *PSMR_DEVMODE;

///////////////////////////////////////////////////////////////
// SMR_FONT - FONT data
///////////////////////////////////////////////////////////////
// 
typedef struct tagSMRFONT{ 
    SMR smr; 
    BYTE FONTData[];
} SMR_FONT, *PSMR_FONT;

///////////////////////////////////////////////////////////////
// SMR_EXTFONT - Extended Font Data
///////////////////////////////////////////////////////////////
// 
// Contains neg. distance to start of
// Font Data
// Font data is typically embedded as
// GDICOMMENT in the prev EMF data
// 
typedef struct tagEXTFONT{ 
    SMREXT smrext;
} SMR_EXTFONT, *PSMR_EXTFONT;

///////////////////////////////////////////////////////////////
// SMR_EOPAGE - End of Page
///////////////////////////////////////////////////////////////
// 
// Contains neg. distance to
// start of page record
//
typedef struct tagSMREOPAGE{ 
    SMREXT smrext; 
} SMR_EOPAGE, *PSMR_EOPAGE;

теперь о EMF формате:


The EMF streams include in the Windows SPL files include various undocumented records.

Including the following:

WINVER >= #0500 (Windows 2000)
EMR_DRAWESCAPE 105 (#69)
EMR_EXTESCAPE 106 (#6A)
EMR_STARTDOC 107 (#6B)
EMR_SMALLTEXTOUT 108 (#6C)
EMR_FORCEUFIMAPPING 109 (#6D)
EMR_NAMEDESCAPE 110 (#6E)
A A
EMR_TRANSPARENTDIB 117 (#75)
A A
EMR_SETLINKEDUFIS 119 (#77)
EMR_SETTEXTJUSTIFICATION 120 (#78)

уточнения

The following information is provided as is, and I take no responsibility for the correctness.

Код

TYPE
  EMR_EXTESCAPE = RECORD
    emr : EMR;
    nEscape : DWORD;
    nSize : DWORD; // == sizeof(DRAWPATRECT)
    pattern : DRAWPATRECT;
  END;


The following information is provided as is, and I take no responsibility for the correctness.

The EMR record type 108 can be 2 different records. EMR_SMALLTEXTOUT or EMR_SMALLTEXTOUTCLIP. Look at the flags in fOptions, to see what type is used. The fOptions field also specifies if the ANSI or UNICODE version is used.

The interpretation of the reference point depends on the current text-alignment mode. An application can retrieve this mode by calling the GetTextAlign function; an application can alter this mode by calling the SetTextAlign function.

By default, the current position is not used or updated by this function. However, an application can call the SetTextAlign function with the fMode parameter set to TA_UPDATECP to permit the system to use and update the current position each time the application calls TextOut for a specified device context. When this flag is set, the system ignores the nXStart and nYStart parameters on subsequent TextOut calls.


Код

//Structure select flags
//Extra flags in fuOptions, see also ExtTextOut function
CONST
  SMALLTEXT_TYPE_ANSI = $200; 
      // if set use ANSI version else UNICODE
  SMALLTEXT_TYPE_WITHOUT_CLIP = $100; 
      // if set use EMR_SMALLTEXTOUT else use EMR_SMALLTEXTOUTCLIP

//Structures
TYPE
  EMR_SMALLTEXTOUTCLIPA = RECORD
      emr: EMR;
      ptlReference: TPoint; //might be in negative numbers, so take abs
      nChars: DWORD;
      fuOptions: DWORD; // this record type
        // != SMALLTEXT_TYPE_WITHOUT_CLIP
        // == SMALLTEXT_TYPE_ANSI 
        // also holds fuOptions like in the ExtTextOut function 
      iGraphicsMode: DWORD; //See iMode parameter of SetGraphicsMode 
      exScale: Single; { X and Y scales from Page units to .01mm units}
      eyScale: Single; { if graphics mode is GM_COMPATIBLE.}
      rclClip: TRect;
      cString: Array[0..0] of char; { This is followed by the string array}
  END;

  EMR_SMALLTEXTOUTCLIPW = RECORD
      emr: EMR;
      ptlReference: TPoint;
      nChars: DWORD;
      fuOptions: DWORD; // this record type
        // != SMALLTEXT_TYPE_WITHOUT_CLIP
        // != SMALLTEXT_TYPE_ANSI
        // also holds fuOptions like in the ExtTextOut function 
      iGraphicsMode: DWORD; //See iMode parameter of SetGraphicsMode
      exScale: Single; { X and Y scales from Page units to .01mm units}
      eyScale: Single; { if graphics mode is GM_COMPATIBLE.}
      rclClip: TRect;
      cString: Array[0..0] of WideChar; { This is followed by the string array}
  END;
  
  EMR_SMALLTEXTOUTA = RECORD
      emr: EMR; 
      ptlReference: TPoint; 
      nChars: DWORD; 
      fuOptions: DWORD; // this record type
        // == SMALLTEXT_TYPE_WITHOUT_CLIP
        // == SMALLTEXT_TYPE_ANSI
        // also holds fuOptions like in the ExtTextOut function
      iGraphicsMode: DWORD; //See iMode parameter of SetGraphicsMode
      exScale: Single; { X and Y scales from Page units to .01mm units}
      eyScale: Single; { if graphics mode is GM_COMPATIBLE.}
      cString: Array[0..0] of char; { This is followed by the string array}
  END;
  
  EMR_SMALLTEXTOUTW = RECORD
      emr: EMR;
      ptlReference: TPoint;
      nChars: DWORD; 
      fuOptions: DWORD; // this record type
        // == SMALLTEXT_TYPE_WITHOUT_CLIP
        // != SMALLTEXT_TYPE_ANSI
        // also holds fuOptions like in the ExtTextOut function
      iGraphicsMode: DWORD; //See iMode parameter of SetGraphicsMode
      exScale: Single; { X and Y scales from Page units to .01mm units}
      eyScale: Single; { if graphics mode is GM_COMPATIBLE.}
      cString: Array[0..0] of WideChar; { This is followed by the string array}
  END;



Как на Delphi вынуть EMF файл из SPL файла и открыть EMF например в BITMAP или сохранить его в BMP,
расскажите хотя бы теоретически как это сделать ?

Это сообщение отредактировал(а) Girder - 6.9.2005, 14:41
  Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Правила форума "Delphi: Общие вопросы"
SnowyMetalFan
bemsPoseidon
Rrader

Запрещается!

1. Публиковать ссылки на вскрытые компоненты

2. Обсуждать взлом компонентов и делиться вскрытыми компонентами

  • Литературу по Дельфи обсуждаем здесь
  • Действия модераторов можно обсудить здесь
  • С просьбами о написании курсовой, реферата и т.п. обращаться сюда
  • Вопросы по реализации алгоритмов рассматриваются здесь
  • 90% ответов на свои вопросы можно найти в DRKB (Delphi Russian Knowledge Base) - крупнейшем в рунете сборнике материалов по Дельфи


Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, Snowy, MetalFan, bems, Poseidon, Rrader.

 
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | Delphi: Общие вопросы | Следующая тема »


 




[ Время генерации скрипта: 0.0659 ]   [ Использовано запросов: 20 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.