/**
@file uwmf_endian.c
@brief Functions for converting WMF records between Big Endian and Little Endian byte orders.
*/
/*
File: uwmf_endian.c
Version: 0.1.5
Date: 28-MAY-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 <stddef.h> /* for offsetof() */
#include <string.h>
#include "uwmf.h"
#include "uwmf_endian.h"
// hide almost everything in this file from Doxygen
//! \cond
/* Prototypes for functions used here and defined in uemf_endian.c, but which are not supposed
to be used in end user code. */
void bitmapinfo_swap(char *Bmi);
/* **********************************************************************************************
These functions Swap standard objects used in the WMR records.
The low level ones do not append EOL.
*********************************************************************************************** */
/**
\brief Swap U_BITMAP16 object
\param b U_BITMAP16 object
*/
void bitmap16_swap(
char *b
){
/* Planes and BitsPixel are bytes, so no swap needed */
/* Bits[] pixel data should already be in order */
}
/**
\brief Swap a U_BRUSH object.
\param b U_BRUSH object.
style bColor bHatch
U_BS_SOLID ColorRef Object Not used (bytes present???)
U_BS_NULL ignored ignored (bytes present???).
U_BS_PATTERN ignored Bitmap16 object holding patern
U_BS_DIBPATTERNPT ColorUsage Enum DIB object
U_BS_HATCHED ColorRef Object HatchStyle Enumeration
*/
void brush_swap(
char *b,
int torev
){
int Style;
/* Color is already in the right order */
switch(Style){
case U_BS_SOLID:
break;
case U_BS_NULL:
break;
case U_BS_PATTERN:
break;
case U_BS_DIBPATTERNPT:
break;
case U_BS_HATCHED:
break;
}
}
/**
\brief Swap a U_FONT object from pointer.
\param lf U_FONT object
*/
void font_swap(
char *f
){
/* Other fields are single bytes */
}
/**
\brief Swap a pointer to a U_PALETTE object.
\param lp Pointer to a U_PALETTE object.
*/
void palette_swap(
char *p
){
/* PalEntries[1] is byte ordered, so no need to swap */
}
/**
\brief Swap a U_PEN object.
\param p U_PEN object
*/
void pen_swap(
char *p
){
/* Color already in order */
}
/* there are no
void rect16_ltrb_swap()
void rect16_brtl_swap()
because rectangles are swapped using U_swap2 as an array of 4 int16 values.
*/
/**
\brief Swap U_REGION object
\param rect U_REGION object
\param torev
PARTIAL IMPLEMENTATION
*/
void region_swap(
char *reg,
int torev
){
int Size;
}
/**
\brief Swap U_BITMAPCOREHEADER object
\param ch U_BITMAPCOREHEADER object
*/
void bitmapcoreheader_swap(
char *ch
){
}
/** LogBrushW Object WMF PDF 2.2.2.10
\brief Swap a U_WLOGBRUSH object.
\param lb U_WLOGBRUSH object.
style Color Hatch
U_BS_SOLID ColorRef Object Not used (bytes present???)
U_BS_NULL ignored ignored (bytes present???).
U_BS_PATTERN ignored not used (Action is not strictly defined)
U_BS_DIBPATTERN ignored not used (Action is not strictly defined)
U_BS_DIBPATTERNPT ignored not used (Action is not strictly defined)
U_BS_HATCHED ColorRef Object HatchStyle Enumeration
*/
void wlogbrush_swap(
char *lb
){
/* Color is already in order */
}
/**
\brief Swap U_POLYPOLY object from pointer
\param pp PU_POLYPOLY object
*/
void polypolygon_swap(
char *pp,
int torev
){
int i,totPoints;
if(torev){
}
if(!torev){
}
}
/**
\brief Swap U_SCAN object
\param pp U_SCAN object
*/
void scan_swap(
char *sc,
int torev
){
int count;
}
/**
\brief Swap a summary of a DIB header
A DIB header in an WMF may be either a BitmapCoreHeader or BitmapInfoHeader.
\param dh void pointer to DIB header
*/
void dibheader_swap(
char *dh,
int torev
){
int Size;
if(Size == 0xC){
}
else {
}
}
/**
\brief Swap WMF header object
\param head uint8_t pointer to header
\returns size of entire header structure
If the header is preceded by a placeable struture, Swap that as well.
*/
int wmfheader_swap(
char *contents,
int torev
){
int size=0;
if(Key == 0x9AC6CDD7){
}
return(size);
}
/* **********************************************************************************************
These functions contain shared code used by various U_WMR*_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.
*********************************************************************************************** */
/* Size16 EVERY record type should call this, directly or indirectly*/
}
/* Size16, move to data, Single 32bit followed by array of N16 U_POINT16 */
}
/* Single 16bit nPoints followed by array of nPoints U_POINT16 */
int nPoints;
}
/* all records that specify palette objects */
}
/* all records that have N int16 values, unconditionally swapped */
}
/* like floodfill */
}
/* **********************************************************************************************
These are the core WMR functions, each creates a particular type of record.
All return these records via a char* pointer, which is NULL if the call failed.
They are listed in order by the corresponding U_EMR_* index number.
*********************************************************************************************** */
/**
\brief Swap a pointer to a U_WMR_whatever record which has not been implemented.
\param name name of this type of record
\param contents pointer to a buffer holding all EMR records
\param recnum number of this record in contents
\param off offset to this record in contents
*/
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
int L2;
/* string is in bytes, do not swap that */
}
}
else { /* yes bitmap */
}
}
}
else { /* yes bitmap */
}
}
}
}
/* Handle data swapping for three types only, anything else end user code must handle */
}
}
}
}
}
}
}
}
}
}
}
}
}
if(torev){
}
if(!torev){
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
else { /* yes bitmap */
}
}
}
else { /* yes bitmap */
}
}
int Style;
if(Style == U_BS_PATTERN){
}
else {
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
/* pattern array byte order already correct? */
}
}
}
}
}
}
}
//! \endcond
/**
\brief Convert an entire WMF in memory from Big Endian to Little Endian (or vice versa).
\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
\param onerec 1 if this is operating on a single record instead of an entire file
Normally this would be called immediately before writing the data to a file
or immediately after reading the data from a file.
*/
char *record;
int recnum;
int offset=0;
if(!onerec){
off = wmfheader_swap(record,torev); fflush(stdout); /* WMF header is not a normal record, handle it separately */
}
OK = 1;
while(OK){
//printf("DEBUG U_wmf_endian before switch record:%d offset:%d type:%d name:%s Size16:%d\n",recnum,offset,iType,U_wmr_names(iType),Size16);fflush(stdout);
switch (iType)
{
} //end of switch
if(onerec)break;
recnum++;
} //end of while
return(1);
}
#ifdef __cplusplus
}
#endif