/**
@file uwmf_print.c
@brief Functions for printing WMF records
*/
/*
File: uwmf_print.c
Version: 0.0.6
Date: 21-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() macro */
#include <string.h>
#include "uwmf_print.h"
//! \cond
#define UNUSED(x) (void)(x)
/* **********************************************************************************************
These functions print standard objects used in the WMR records.
The low level ones do not append EOL.
*********************************************************************************************** */
/* many of these are implemented in uemf_print.c and not replicated here */
/**
\brief Print 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_print(
U_BRUSH b
){
switch(b.Style){
case U_BS_SOLID:
break;
case U_BS_NULL:
printf("Null");
break;
case U_BS_PATTERN:
printf("Pattern:(not shown)");
break;
case U_BS_DIBPATTERNPT:
printf("DIBPattern:(not shown)");
break;
case U_BS_HATCHED:
break;
}
}
/**
\brief Print a U_FONT object from a char *pointer.
The U_FONT struct object may not be properly aligned, but all of the fields within it will
OK for alignment.
\param font U_FONT object (as a char * pointer)
*/
void font_print(
const char *font
){
}
/**
\brief Print a U_PLTNTRY object.
\param pny U_PLTNTRY object.
*/
void pltntry_print(
){
}
/**
\brief Print a pointer to a U_PALETTE object.
\param p Pointer to a U_PALETTE object
\param PalEntries Array of Palette Entries
*/
void palette_print(
const U_PALETTE *p,
const char *PalEntries
){
int i;
if(p->NumEntries && PalEntries){
}
}
}
/**
\brief Print a U_PEN object.
\param p U_PEN object
uint16_t Style; //!< PenStyle Enumeration
uint16_t Width; //!< Pen Width in object dimensions
uint16_t unused; //!< unused
union {
U_COLORREF Color; //!< Pen color (NOT aligned on 4n byte boundary!)
uint16_t Colorw[2]; //!< reassemble/store the Color value using these, NOT Color.
};
*/
void pen_print(
U_PEN p
){
}
/**
\brief Print U_RECT16 object
Prints in order left, top, right, bottom
\param rect U_RECT16 object
*/
void rect16_ltrb_print(
){
}
/**
\brief Print U_RECT16 object
Some WMF rects use the order bottom, right, top, left. These are passed in using
the same structure as for a normal U_RECT16 so:
position holds
left bottom
top right
right top
bottom left
This is used by WMR_RECTANGLE and many others.
\param rect U_RECT16 object
*/
void rect16_brtl_print(
){
}
/**
\brief Print U_REGION object from a char * pointer.
\param region U_REGION object
*/
void region_print(
const char *region
){
}
/**
\brief Print U_BITMAP16 object
\param b U_BITMAP16 object
*/
void bitmap16_print(
){
}
/**
\brief Print U_BITMAPCOREHEADER object
\param ch U_BITMAPCOREHEADER object
*/
void bitmapcoreheader_print(
){
}
/** LogBrushW Object WMF PDF 2.2.2.10
\brief Print a U_LOGBRUSHW object.
\param lb U_LOGBRUSHW 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_print(
const char *lb
){
switch(Style){
case U_BS_SOLID:
break;
case U_BS_NULL:
printf("Null");
break;
case U_BS_PATTERN:
printf("Pattern:(not implemented)");
break;
case U_BS_DIBPATTERN:
printf("DIBPattern:(not implemented)");
break;
case U_BS_DIBPATTERNPT:
printf("DIBPatternPt:(not implemented)");
break;
case U_BS_HATCHED:
break;
}
}
/**
\brief Print U_POLYPOLY object from pointer
\param nPolys Number of elements in aPolyCounts
\param aPolyCounts Number of points in each poly (sequential)
\param Points pointer to array of U_POINT16 in memory. Probably not aligned.
*/
void polypolygon_print(
const uint16_t *aPolyCounts,
const char *Points
){
int i,j;
for(i=0; i<nPolys; i++, aPolyCounts++){
printf(" Polygon[%d]: ",i);
}
}
}
/**
\brief Print U_SCAN object
\param sc U_SCAN object
*/
void scan_print(
){
printf("data:(not shown)");
}
/**
\brief Print a summary of a DIB header
\param dh void pointer to DIB header
A DIB header in an WMF may be either a BitmapCoreHeader or BitmapInfoHeader.
*/
if(Size == 0xC ){
printf("(BitmapCoreHeader) ");
}
else {
printf(" (BitmapInfoHeader) ");
}
}
/**
\brief Print WMF header object
\returns size of entire header structure
\param contents pointer to the first byte in the buffer holding the entire WMF file in memory
\param blimit pointer to the byte after the last byte in contents
If the header is preceded by a placeable struture, print that as well.
*/
int wmfheader_print(
const char *contents,
const char *blimit
){
printf("WMF, Placeable: ");
}
else {
printf("WMF, Not Placeable\n");
}
return(size);
}
/* **********************************************************************************************
These functions contain shared code used by various U_WMR*_print 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.
*********************************************************************************************** */
int i;
printf(" Points: ");
for(i=0;i<nPoints; i++){
memcpy(&pt, aPoints + i*4, sizeof(U_POINT16)); /* aPoints U_POINT16 structure may not be aligned, so copy it out */
}
printf("\n");
}
/* **********************************************************************************************
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_WMR_* index number.
*********************************************************************************************** */
/**
\brief Print a pointer to a U_WMR_whatever record which has not been implemented.
\param contents pointer to a buffer holding a WMR record
*/
printf(" Not Implemented!\n");
}
}
if(size>0){
}
}
if(size>0){
}
}
if(size>0){
}
}
if(size>0){
}
}
/* This record type has only the common 6 bytes, so nothing (else) to print */
}
if(size>0){
}
}
if(size>0){
}
}
if(size>0){
}
}
if(size>0){
}
}
if(size){
}
}
if(size){
}
}
if(size){
}
}
if(size){
}
}
if(size){
}
}
if(size){
}
}
if(size > 0){
}
}
if(size){
}
}
if(size > 0){
}
}
if(size){
}
}
if(size > 0){
}
}
if(size > 0){
printf(" Rect:");
printf("\n");
}
}
if(size > 0){
printf(" Rect:");
printf("\n");
}
}
if(size > 0){
}
}
if(size > 0){
printf(" Rect:");
printf("\n");
}
}
if(size > 0){
}
}
if(size > 0){
}
}
if(size > 0){
printf(" Rect:");
printf("\n");
}
}
if(size > 0){
printf(" Rect:");
printf("\n");
}
}
if(size > 0){
}
}
/* This record type has only the common 6 bytes, so nothing (else) to print */
}
if(size > 0){
}
}
if(size > 0){
}
}
const char *string;
if(size > 0){
}
}
const char *px;
if(size > 0){
else { printf(" Bitmap16: none\n"); }
}
}
const char *px;
if(size > 0){
else { printf(" Bitmap16: none\n"); }
}
}
const char *Data;
if(size > 0){
}
}
const char *Data;
if(size > 0){
}
}
const char *Data;
if(size > 0){
if((Escape == U_MFE_SETLINECAP) || (Escape == U_MFE_SETLINEJOIN) || (Escape == U_MFE_SETMITERLIMIT)){
}
else {
printf(" Data: (not shown)\n");
}
}
}
/* This record type has only the common 6 bytes, so nothing (else) to print */
}
if(size > 0){
}
}
if(size > 0){
}
}
if(size > 0){
}
}
if(size>0){
}
}
if(size>0){
}
}
if(size>0){
}
}
if(size>0){
}
}
if(size > 0){
}
}
if(size > 0){
}
}
const char *string;
int i;
if(size > 0){
}
printf(" Dx:");
printf("\n");
}
}
const char *dib;
if(size > 0){
}
}
if(size > 0){
}
}
/* This record type has only the common 6 bytes, so nothing (else) to print */
}
const char *PalEntries;
if(size > 0){
}
}
const char *PalEntries;
if(size > 0){
}
}
const char *Points;
if(size > 0){
}
}
if(size>0){
}
}
const char *dib;
if(size > 0){
else { printf(" DIB: none\n"); }
}
}
const char *dib;
if(size > 0){
else { printf(" DIB: none\n"); }
}
}
const char *TBm16;
const char *dib;
if(size > 0){
if(TBm16){
}
else { /* from DIB */
}
}
}
const char *dib;
if(size > 0){
else { printf(" DIB: none\n"); }
}
}
if(size > 0){
}
}
if(size>0){
}
}
const char *PalEntries;
if(size > 0){
}
}
int pasize;
int i;
const char *Pattern;
if(size > 0){
/* BM16 is truncated, but bitmap16_print does not get into the part that was omitted */
printf(" Pattern: ");
for(i=0;i<pasize;i++){
}
printf("\n");
}
}
if(size > 0){
}
}
const char *font; /* Note, because of possible struct alignment issue have to use char * to reference the data */
if(size > 0){
printf(" Font:");
printf("\n");
}
}
const char *brush; /* Note, because of possible struct alignment issue have to use char * to reference the data */
if(size > 0){
printf(" Brush:");
printf("\n");
}
}
}
}
const char *region; /* Note, because of possible struct alignment issue have to use char * to reference the data */
if(size > 0){
printf(" Brush:");
}
}
//! \endcond
/**
\brief Print any record in a wmf
\returns record length for a normal record, 0 for WMREOF, -1 for a bad record
\param contents pointer to a buffer holding all WMR records
\param blimit one byte past the last WMF record in memory.
\param recnum number of this record in contents
\param off offset to this record in contents
*/
/* Check that the record size is OK, abort if not.
Pointer math might wrap, so check both sides of the range */
if(!size)return(-1);
#if U_BYTE_SWAP
//This is a Big Endian machine, WMF crc values must be calculated on Little Endian form
if(!swapbuf)return(-1);
#else
#endif
printf("%-30srecord:%5d type:%-4u offset:%8d rsize:%8u crc32:%8.8X\n",
switch (iType)
{
default: U_WMRNOTIMPLEMENTED_print(contents); break;
} //end of switch
return(size);
}
#ifdef __cplusplus
}
#endif