/**
@file uemf_endian.c
@brief Functions for converting EMF records between Big Endian and Little Endian byte orders.
EMF files use Little Endian order.
On a Big Endian machine the data must be converted to/from Little Endian when it is writen to/read from a file.
On a Little Endian machine no conversion is required, but it is good to be able to test the routines on either platform.
When "torev" is true these routines convert from the native byte order to the reverse.
When "torev" is false these routines convert from the reverse byte order to the native.
Routines that do not use that variable swap byte order, and the way in which they do so does not depend
on the native byte order.
The only function here which should be called directly is U_emf_endian(), and then,except for testing purposes, only on a BE machine.
Many variables are initialized to zero even though they will always be set because
some versions of gcc give spurious "may be used uninitialized" warnings otherwise.
*/
/*
File: uemf_endian.c
Version: 0.0.21
Date: 23-APR-2015
Author: David Mathog, Biology Division, Caltech
email: mathog@caltech.edu
Copyright: 2015 David Mathog and California Institute of Technology (Caltech)
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "uemf.h"
#include "uemf_endian.h"
// hide almost everuything in here from Doxygen
//! \cond
/* **********************************************************************************************
These functions convert standard objects used in the EMR records.
*********************************************************************************************** */
}
}
/* Note: U_swap4 is also used by uwmf_endian.c, in cases where the 32 bit data is not aligned on a 4 byte boundary */
}
}
/**
U_COLORREF and U_RGBQUAD do NOT need to be swapped, they are always stored in memory in the proper order.
*/
/**
\brief Convert rect and rectl objects from Upper Left and Lower Right corner points.
\param rect U_RECTL object
\param count number to convert
*/
void rectl_swap(
unsigned int count
){
}
/**
\brief Convert a U_SIZEL object.
\param sz U_SizeL object
\param count number to convert
*/
void sizel_swap(
unsigned int count
){
}
/**
\brief Convert a U_POINTL object
\param pt U_POINTL object
\param count number to convert
*/
void pointl_swap(
unsigned int count
){
}
/**
\brief Convert a U_POINT16 object
\param pt U_POINT16 object
\param count number to convert
*/
void point16_swap(
unsigned int count
){
}
/**
\brief Convert a U_TRIVERTEX object.
\param tv U_TRIVERTEX object.
\param count number to convert
*/
void trivertex_swap(
unsigned int count
){
}
}
/**
\brief Convert a U_GRADIENT3 object.
\param tv U_GRADIENT3 object.
\param count number to convert
*/
void gradient3_swap(
unsigned int count
){
}
/**
\brief Convert a U_GRADIENT4 object.
\param tv U_GRADIENT4 object.
\param count number to convert
*/
void gradient4_swap(
unsigned int count
){
}
/**
\brief Convert a U_LOGBRUSH object.
\param lb U_LOGBRUSH object.
*/
void logbrush_swap(
){
// ordered bytes: lbColor
}
/**
\brief Convert a U_XFORM object.
\param xform U_XFORM object
*/
void xform_swap(
){
}
/**
\brief Convert a U_CIEXYZTRIPLE object
\param cie3 U_CIEXYZTRIPLE object
*/
void ciexyztriple_swap(
){
}
/**
\brief Convert a U_LOGCOLORSPACEA object.
\param lcsa U_LOGCOLORSPACEA object
*/
void logcolorspacea_swap(
){
// ordered bytes: lcsGammaRGB
// ordered bytes: lcsFilename
}
/**
\brief Convert a U_LOGCOLORSPACEW object.
\param lcsa U_LOGCOLORSPACEW object
*/
void logcolorspacew_swap(
){
// ordered bytes: lcsGammaRGB
// UTF-16LE, already in order: lcsFilename
}
/**
\brief Convert a U_LOGFONT object.
\param lf U_LOGFONT object
*/
void logfont_swap(
){
// ordered bytes: lfItalic lfUnderline lfStrikeOut lfCharSet lfOutPrecision lfClipPrecision lfQuality lfPitchAndFamily
// UTF16-LE, already in order
}
/**
\brief Convert a U_LOGFONT_PANOSE object.
\return U_LOGFONT_PANOSE object
*/
void logfont_panose_swap(
){
// UTF-16LE, already in order: elfFullName
// UTF-16LE, already in order: elfStyle
// ordered bytes: elfVendorId
// ordered bytes: elfPanose
}
/**
\brief Convert a U_BITMAPINFOHEADER object.
\param Bmi U_BITMAPINFOHEADER object
*/
void bitmapinfoheader_swap(
){
U_swap4(&(Bmi->biCompression),6); // biCompression biSizeImage biXPelsPerMeter biYPelsPerMeter biClrUsed biClrImportant
}
/**
\brief Convert a Pointer to a U_BITMAPINFO object.
\param Bmi Pointer to a U_BITMAPINFO object
*/
void bitmapinfo_swap(
const char *Bmi
){
// ordered bytes: bmiColors
}
/**
\brief Swap the ordered bytes in a DIB and verify that the sizes are OK
\return 1 on success, 0 on failure
\param record EMF record that contains a DIB pixel array
\param iUsage DIBcolors Enumeration
\param offBmi offset from the start of the record to the start of the bitmapinfo structure
\param cbBmi declared space for the bitmapinfo structure in the record
\param offBits offset from the start of the record to the start of the bitmap
\param cbBits declared space for the bitmap in the record (amount used may be less than this)
\param blimit one byte past the end of the record.
\param torev 1 for native to reversed, 0 for reversed to native
This method can only test DIBs that hold Microsoft's various bitmap types. PNG or JPG is just a bag
of bytes, and there is no possible way to derive from the known width and height how big it should be.
*/
int DIB_swap(
const char *record,
const char *blimit,
int torev
){
int bs;
int usedbytes;
if(iUsage == U_DIB_RGB_COLORS){
// next call returns pointers and values, but allocates no memory
if(torev){
}
if(!torev){
}
// sanity checking
// this is the only DIB type where we can calculate how big it should be when stored in the EMF file
if(bs<1){
}
else {
}
}
}
else {
}
return(1);
}
/**
\brief Convert a pointer to a U_EXTLOGPEN object.
\param elp PU_EXTLOGPEN object
\param blimit one byte past the end of the record
*/
int extlogpen_swap(
const char *blimit,
int torev
){
int count=0;
// ordered bytes: elpColor
if(torev){
}
if(!torev){
}
return(1);
}
/**
\brief Convert a U_LOGPEN object.
\param lp U_LOGPEN object
*/
void logpen_swap(
){
// ordered bytes: lopnColor
}
/**
\brief Convert a pointer to a U_LOGPALETTE object.
\param lp Pointer to a U_LOGPALETTE object.
*/
void logpalette_swap(
){
// ordered bytes: palPalEntry[]
}
/**
\brief Convert a U_RGNDATAHEADER object.
\param rdh U_RGNDATAHEADER object
*/
void rgndataheader_swap(
){
}
/**
\return 1 on success, 0 on failure
\brief Convert a pointer to a U_RGNDATA object.
\param rd pointer to a U_RGNDATA object.
\param cbRgnData size of the U_RGNDATA object.
*/
int rgndata_swap(
int cbRgnData,
int torev
){
int count = 0;
if(torev){
}
if(!torev){
}
return(1);
}
/**
\brief Convert a U_COLORADJUSTMENT object.
\param ca U_COLORADJUSTMENT object.
*/
void coloradjustment_swap(
){
U_swap2(ca,12); // caSize caFlags caIlluminantIndex caRedGamma caGreenGamma caBlueGamma caReferenceBlack caReferenceWhite caContrast caBrightness caColorfulness caRedGreenTint
}
/**
\brief Convert a pointer to a U_PIXELFORMATDESCRIPTOR object.
\param pfd pointer to a U_PIXELFORMATDESCRIPTOR object.
*/
){
// ordered bytes: iPixelType cColorBits cRedBits cRedShift cGreenBits cGreenShift cBlueBits cBlueShift cAlphaBits cAlphaShift cAccumBits cAccumRedBits cAccumGreenBits cAccumBlueBits cAccumAlphaBits cDepthBits cStencilBits cAuxBuffers iLayerType bReserved
}
/**
\brief Convert a Pointer to a U_EMRTEXT record
\param pemt Pointer to a U_EMRTEXT record
\param record Pointer to the start of the record which contains this U_EMRTEXT
\param blimit one byte past the end of the record.
\param torev 1 for native to reversed, 0 for reversed to native
*/
int emrtext_swap(
char *record,
const char *blimit,
int torev
){
int off;
if(torev){
}
if(!torev){
}
if(!(fOptions & U_ETO_NO_RECT)){
}
if(torev){
}
// ordered bytes OR UTF16-LE: the string at offString
if(!torev){
}
return(1);
}
/* **********************************************************************************************
These functions contain shared code used by various U_EMR*_swap functions. These should NEVER be called
by end user code and to further that end prototypes are NOT provided and they are hidden from Doxygen.
These all have this form:
void core1_swap(char *record, int torev){
but some do not actually use torev.
*********************************************************************************************** */
// all core*_swap call this, U_EMRSETMARGN_swap and some others all it directly
// numbered as core5 to be consistent with uemf.c, but must appear before the others as there is no prototype
if(!record)return(0);
return(1);
}
// Functions with the same form starting with U_EMRPOLYBEZIER_swap
int count=0;
if(torev){
}
if(!torev){
}
return(1);
}
// Functions with the same form starting with U_EMRPOLYPOLYLINE_swap
int count=0;
int nPolys=0;
if(torev){
}
if(!torev){
}
return(1);
}
// Functions with the same form starting with U_EMRSETMAPMODE_swap
return(1);
}
// Functions taking a single U_RECT or U_RECTL, starting with U_EMRELLIPSE_swap, also U_EMRFILLPATH_swap,
return(1);
}
// Functions with the same form starting with U_EMRPOLYBEZIER16_swap
int count=0;
if(torev){
}
if(!torev){
}
return(1);
}
// Records with the same form starting with U_EMRSETWINDOWEXTEX_swap, that is, all with two uint32_t values after the emr
return(1);
}
// For U_EMREXTTEXTOUTA and U_EMREXTTEXTOUTW, type=0 for the first one
if(torev){
}
if(!torev){
}
return(1);
}
// Functions that take a rect and a pair of points, starting with U_EMRARC_swap
return(1);
}
// Functions with the same form starting with U_EMRPOLYPOLYLINE16_swap
int count=0;
int nPolys=0;
if(torev){
}
if(!torev){
}
return(1);
}
// Functions with the same form starting with U_EMRINVERTRGN_swap and U_EMRPAINTRGN_swap,
int cbRgnData=0;
if(torev){
}
if(!torev){
}
}
// common code for U_EMRCREATEMONOBRUSH_swap and U_EMRCREATEDIBPATTERNBRUSHPT_swap,
if(torev){
}
if(!torev){
}
return(1);
}
// common code for U_EMRALPHABLEND_swap and U_EMRTRANSPARENTBLT_swap,
if(torev){
if(!DIB_swap(record, iUsageSrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc, blimit, torev))return(0);
}
// ordered bytes: Blend
// ordered bytes: crBkColorSrc
if(!torev){
if(!DIB_swap(record, iUsageSrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc, blimit, torev))return(0);
}
return(1);
}
/* **********************************************************************************************
These are the core EMR_swap functions, each converts a particular type of record.
All operate in place on the chunk of memory holding that record.
Some of these have offsets or counts which, if corrupt or evil would result in access outside
the record. These cases return a status value of 0 if that happens, 1 on success. Other
records which do not have these issues do not return a status value.
They are listed in order by the corresponding U_EMR_* index number.
*********************************************************************************************** */
/**
All of the record level (hidden) functions have this form:
\brief Convert a pointer to a U_EMR_whatever record which has not been implemented.
\param record pointer to a buffer holding the EMR record
\param torev 1 for native to reversed, 0 for reversed to native
*/
fprintf(stderr,"EMF WARNING: could not swap data bytes on record because that type has not been implemented!\n");
}
// U_EMRHEADER 1
if(torev){
}
if(!torev){
}
// UTF16-LE Description
){
if(torev){
}
if(!torev){
}
){
}
}
return(1);
}
// U_EMRPOLYBEZIER 2
}
// U_EMRPOLYGON 3
}
// U_EMRPOLYLINE 4
}
// U_EMRPOLYBEZIERTO 5
}
// U_EMRPOLYLINETO 6
}
// U_EMRPOLYPOLYLINE 7
}
// U_EMRPOLYPOLYGON 8
}
// U_EMRSETWINDOWEXTEX 9
}
// U_EMRSETWINDOWORGEX 10
}
// U_EMRSETVIEWPORTEXTEX 11
}
// U_EMRSETVIEWPORTORGEX 12
}
// U_EMRSETBRUSHORGEX 13
}
// U_EMREOF 14
int off=0;
int cbPalEntries=0;
if(torev){
}
if(!torev){
}
if(cbPalEntries){
if(IS_MEM_UNSAFE(record, pEmr->offPalEntries + 2*2, blimit))return(0); // 2 16 bit values in U_LOGPALLETE
// U_LOGPLTNTRY values in pallette are ordered data
}
return(1);
}
// U_EMRSETPIXELV 15
// ordered bytes: crColor
return(1);
}
// U_EMRSETMAPPERFLAGS 16
return(1);
}
// U_EMRSETMAPMODE 17
}
// U_EMRSETBKMODE 18
}
// U_EMRSETPOLYFILLMODE 19
}
// U_EMRSETROP2 20
}
// U_EMRSETSTRETCHBLTMODE 21
}
// U_EMRSETTEXTALIGN 22
}
// U_EMRSETCOLORADJUSTMENT 23
return(1);
}
// U_EMRSETTEXTCOLOR 24
// ordered bytes: crColor
return(1);
}
// U_EMRSETBKCOLOR 25
// ordered bytes: crColor
return(1);
}
// U_EMROFFSETCLIPRGN 26
}
// U_EMRMOVETOEX 27
}
// U_EMRSETMETARGN 28
}
// U_EMREXCLUDECLIPRECT 29
}
// U_EMRINTERSECTCLIPRECT 30
}
// U_EMRSCALEVIEWPORTEXTEX 31
}
// U_EMRSCALEWINDOWEXTEX 32
}
// U_EMRSAVEDC 33
}
// U_EMRRESTOREDC 34
}
// U_EMRSETWORLDTRANSFORM 35
return(1);
}
// U_EMRMODIFYWORLDTRANSFORM 36
return(1);
}
// U_EMRSELECTOBJECT 37
return(1);
}
// U_EMRCREATEPEN 38
return(1);
}
// U_EMRCREATEBRUSHINDIRECT 39
return(1);
}
// U_EMRDELETEOBJECT 40
return(1);
}
// U_EMRANGLEARC 41
return(1);
}
// U_EMRELLIPSE 42
}
// U_EMRRECTANGLE 43
}
// U_EMRROUNDRECT 44
return(1);
}
// U_EMRARC 45
}
// U_EMRCHORD 46
}
// U_EMRPIE 47
}
// U_EMRSELECTPALETTE 48
}
// U_EMRCREATEPALETTE 49
return(1);
}
// U_EMRSETPALETTEENTRIES 50
// ordered bytes: aPalEntries[]
return(1);
}
// U_EMRRESIZEPALETTE 51
}
// U_EMRREALIZEPALETTE 52
}
// U_EMREXTFLOODFILL 53
// ordered bytes: crColor
return(1);
}
// U_EMRLINETO 54
}
// U_EMRARCTO 55
}
// U_EMRPOLYDRAW 56
int count=0;
if(torev){
}
if(!torev){
}
// single byte data abTypes
return(1);
}
// U_EMRSETARCDIRECTION 57
}
// U_EMRSETMITERLIMIT 58
}
// U_EMRBEGINPATH 59
}
// U_EMRENDPATH 60
}
// U_EMRCLOSEFIGURE 61
}
// U_EMRFILLPATH 62
}
// U_EMRSTROKEANDFILLPATH 63
}
// U_EMRSTROKEPATH 64
}
// U_EMRFLATTENPATH 65
}
// U_EMRWIDENPATH 66
}
// U_EMRSELECTCLIPPATH 67
}
// U_EMRABORTPATH 68
}
// U_EMRUNDEF69 69
// U_EMRCOMMENT 70 Comment (any binary data, interpretation is program specific)
int cbData = 0;
if(torev){
}
if(!torev){
}
// program specific data, presumably byte ordered, otherwise, not portable
return(1);
}
// U_EMRFILLRGN 71
int cbRgnData=0;
if(torev){
}
if(!torev){
}
}
// U_EMRFRAMERGN 72
int cbRgnData=0;
if(torev){
}
if(!torev){
}
}
// U_EMRINVERTRGN 73
}
// U_EMRPAINTRGN 74
}
// U_EMREXTSELECTCLIPRGN 75
int cbRgnData=0;
if(torev){
}
if(!torev){
}
}
// U_EMRBITBLT 76
if(torev){
if(!DIB_swap(record, iUsageSrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc, blimit, torev))return(0);
}
// ordered bytes: crBkColorSrc
if(!torev){
if(!DIB_swap(record, iUsageSrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc, blimit, torev))return(0);
}
return(1);
}
// U_EMRSTRETCHBLT 77
if(torev){
if(!DIB_swap(record, iUsageSrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc, blimit, torev))return(0);
}
// ordered bytes: crBkColorSrc
if(!torev){
if(!DIB_swap(record, iUsageSrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc, blimit, torev))return(0);
}
return(1);
}
// U_EMRMASKBLT 78
if(torev){
if(!DIB_swap(record, iUsageSrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc, blimit, torev))return(0);
if(!DIB_swap(record, iUsageMask, offBmiMask, cbBmiMask, offBitsMask, cbBitsMask, blimit, torev))return(0);
}
// ordered bytes: crBkColorSrc
if(!torev){
if(!DIB_swap(record, iUsageSrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc, blimit, torev))return(0);
if(!DIB_swap(record, iUsageMask, offBmiMask, cbBmiMask, offBitsMask, cbBitsMask, blimit, torev))return(0);
}
return(1);
}
// U_EMRPLGBLT 79
if(torev){
if(!DIB_swap(record, iUsageSrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc, blimit, torev))return(0);
if(!DIB_swap(record, iUsageMask, offBmiMask, cbBmiMask, offBitsMask, cbBitsMask, blimit, torev))return(0);
}
// ordered bytes: crBkColorSrc
if(!torev){
if(!DIB_swap(record, iUsageSrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc, blimit, torev))return(0);
if(!DIB_swap(record, iUsageMask, offBmiMask, cbBmiMask, offBitsMask, cbBitsMask, blimit, torev))return(0);
}
return(1);
}
// U_EMRSETDIBITSTODEVICE 80
if(torev){
if(!DIB_swap(record, iUsageSrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc, blimit, torev))return(0);
}
U_swap4(&(pEmr->offBmiSrc),7); // offBmiSrc cbBmiSrc offBitsSrc cbBitsSrc iUsageSrc iStartScan cScans
if(!torev){
if(!DIB_swap(record, iUsageSrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc, blimit, torev))return(0);
}
return(1);
}
// U_EMRSTRETCHDIBITS 81
if(torev){
if(!DIB_swap(record, iUsageSrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc, blimit, torev))return(0);
}
if(!torev){
if(!DIB_swap(record, iUsageSrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc, blimit, torev))return(0);
}
return(1);
}
// U_EMREXTCREATEFONTINDIRECTW 82
int nSize = 0;
if(torev){
}
if(!torev){
}
}
else { // logfont or logfontExDv (which starts with logfont, which can be swapped, and the rest is already in byte order
}
return(1);
}
// U_EMREXTTEXTOUTA 83
}
// U_EMREXTTEXTOUTW 84
}
// U_EMRPOLYBEZIER16 85
/**
\brief Convert a pointer to a U_EMR_POLYBEZIER16 record.
\param record pointer to a buffer holding the EMR record
*/
}
// U_EMRPOLYGON16 86
}
// U_EMRPOLYLINE16 87
}
// U_EMRPOLYBEZIERTO16 88
}
// U_EMRPOLYLINETO16 89
/**
\brief Convert a pointer to a U_EMR_POLYLINETO16 record.
\param record pointer to a buffer holding the EMR record
*/
}
// U_EMRPOLYPOLYLINE16 90
}
// U_EMRPOLYPOLYGON16 91
}
// U_EMRPOLYDRAW16 92
int count=0;
if(torev){
}
if(!torev){
}
// single byte data abTypes
return(1);
}
// U_EMRCREATEMONOBRUSH 93
}
// U_EMRCREATEDIBPATTERNBRUSHPT_swap 94
}
// U_EMREXTCREATEPEN 95
if(torev){
}
if(!torev){
}
}
// U_EMRPOLYTEXTOUTA 96 NOT IMPLEMENTED, denigrated after Windows NT
// U_EMRPOLYTEXTOUTW 97 NOT IMPLEMENTED, denigrated after Windows NT
// U_EMRSETICMMODE 98
}
// U_EMRCREATECOLORSPACE 99
return(1);
}
// U_EMRSETCOLORSPACE 100
}
// U_EMRDELETECOLORSPACE 101
}
// U_EMRGLSRECORD 102 Not implemented
// U_EMRGLSBOUNDEDRECORD 103 Not implemented
// U_EMRPIXELFORMAT 104
return(1);
}
// U_EMRDRAWESCAPE 105 Not implemented
// U_EMREXTESCAPE 106 Not implemented
// U_EMRUNDEF107 107 Not implemented
// U_EMRSMALLTEXTOUT 108
int fuOptions = 0;
int cChars = 0;
if(torev){
}
if(!torev){
}
if(!(fuOptions & U_ETO_NO_RECT)){
}
// ordered bytes or UTF16-LE TextString
return(1);
}
// U_EMRFORCEUFIMAPPING 109 Not implemented
// U_EMRNAMEDESCAPE 110 Not implemented
// U_EMRCOLORCORRECTPALETTE 111 Not implemented
// U_EMRSETICMPROFILEA 112 Not implemented
// U_EMRSETICMPROFILEW 113 Not implemented
// U_EMRALPHABLEND 114
}
// U_EMRSETLAYOUT 115
}
// U_EMRTRANSPARENTBLT 116
}
// U_EMRUNDEF117 117 Not implemented
// U_EMRGRADIENTFILL 118
int nTriVert=0;
int nGradObj=0;
int ulMode=0;
if(torev){
}
if(!torev){
}
record += sizeof(U_EMRGRADIENTFILL);
if(nTriVert){
}
if(nGradObj){
if( ulMode == U_GRADIENT_FILL_TRIANGLE){
}
}
}
return(1);
}
// U_EMRSETLINKEDUFIS 119 Not implemented
// U_EMRSETTEXTJUSTIFICATION120 Not implemented (denigrated)
// U_EMRCOLORMATCHTOTARGETW 121 Not implemented
// U_EMRCREATECOLORSPACEW 122
// ordered bytes: Data
return(1);
}
//! \endcond
/**
\brief Checks the declared size of a record for consistency
\return 0 on failure, 1 on success
\param record pointer to the start of the EMF record in memory
\param blimit pointer to one byte after the EMF record in memory
\param nSize number of bytes in the record, read from the record
\param iType type of the record, read from the record
\param torev 1 for native to reversed, 0 for reversed to native
Normally this would be called immediately after reading the data from a file.
Verifies that the declared size is consistent with this type of record.
*/
int U_emf_record_sizeok(const char *record, const char *blimit, uint32_t *nSize, uint32_t *iType, int torev){
/* Check that COMMON data in record can be touched without an access violation. If it cannot be
this is either a corrupt EMF or one engineered to cause a buffer overflow. Pointer math
could wrap so check both sides of the range, and fail any indications of such a wrap.
*/
if(!torev){
}
/* Check that the FULL record size is OK, abort if not. */
switch (*iType)
{
// next line, ancient EMF files used a smaller header, to be safe, test for that
// case U_EMR_FORCEUFIMAPPING: rsize = U_SIZE_EMRFORCEUFIMAPPING; break;
// case U_EMR_COLORCORRECTPALETTE: rsize = U_SIZE_EMRCOLORCORRECTPALETTE; break;
// case U_EMR_SETICMPROFILEA: rsize = U_SIZE_EMRSETICMPROFILEA; break;
// case U_EMR_SETICMPROFILEW: rsize = U_SIZE_EMRSETICMPROFILEW; break;
// case U_EMR_SETLINKEDUFIS: rsize = U_SIZE_EMRSETLINKEDUFIS; break;
// case U_EMR_SETTEXTJUSTIFICATION: rsize = U_SIZE_EMRSETTEXTJUSTIFICATION; break;
default: rsize = U_SIZE_EMRNOTIMPLEMENTED; break;
} //end of switch
// record's declared size must be more than the minimum size for this type of record
return(0);
}
return(1);
}
/**
\brief Convert an entire EMF in memory from Big Endian to Little Endian.
\return 0 on failure, 1 on success
\param contents pointer to the buffer holding the entire EMF in memory
\param length number of bytes in the buffer
\param torev 1 for native to reversed, 0 for reversed to native
Normally this would be called immediately before writing the data to a file
or immediately after reading the data from a file.
*/
char *record;
const char *blimit = contents + length; /* should never wrap since it describes a structure in memory */
OK = 1;
off = 0;
recnum = 0;
while(OK){
return(0);
}
switch (iType)
{
case U_EMR_EOF:
OK = 0; /* Exit triggered here */
break;
case U_EMR_CREATEDIBPATTERNBRUSHPT: rstatus=U_EMRCREATEDIBPATTERNBRUSHPT_swap(record, torev); break;
} //end of switch
if(!rstatus){
return(rstatus);
}
recnum++;
} //end of while
return(1);
}
#ifdef __cplusplus
}
#endif