uwmf_print.c revision 17bff5448ba0eb0f9bec0a2834a1944f6b5fbacf
/**
@file uwmf_print.c Functions for printing WMF records
*/
/*
File: uwmf_print.c
Version: 0.0.2
Date: 18-FEB-2013
Author: David Mathog, Biology Division, Caltech
email: mathog@caltech.edu
Copyright: 2012 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"
/* **********************************************************************************************
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 PU_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.
*/
void dibheader_print(const void *dh){
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);
}
// hide these from Doxygen
//! @cond
/* **********************************************************************************************
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");
}
//! @endcond
/* **********************************************************************************************
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
*/
void U_WMRNOTIMPLEMENTED_print(const char *contents){
(void) contents;
printf(" Not Implemented!\n");
}
void U_WMREOF_print(const char *contents){
(void) contents;
}
void U_WMRSETBKCOLOR_print(const char *contents){
if(size>0){
}
}
void U_WMRSETBKMODE_print(const char *contents){
if(size>0){
}
}
void U_WMRSETMAPMODE_print(const char *contents){
if(size>0){
}
}
void U_WMRSETROP2_print(const char *contents){
if(size>0){
}
}
void U_WMRSETRELABS_print(const char *contents){
(void) contents;
/* This record type has only the common 6 bytes, so nothing (else) to print */
}
void U_WMRSETPOLYFILLMODE_print(const char *contents){
if(size>0){
}
}
void U_WMRSETSTRETCHBLTMODE_print(const char *contents){
if(size>0){
}
}
void U_WMRSETTEXTCHAREXTRA_print(const char *contents){
if(size>0){
}
}
void U_WMRSETTEXTCOLOR_print(const char *contents){
if(size>0){
}
}
void U_WMRSETTEXTJUSTIFICATION_print(const char *contents){
if(size){
}
}
void U_WMRSETWINDOWORG_print(const char *contents){
if(size){
}
}
void U_WMRSETWINDOWEXT_print(const char *contents){
if(size){
}
}
void U_WMRSETVIEWPORTORG_print(const char *contents){
if(size){
}
}
void U_WMRSETVIEWPORTEXT_print(const char *contents){
if(size){
}
}
void U_WMROFFSETWINDOWORG_print(const char *contents){
if(size){
}
}
void U_WMRSCALEWINDOWEXT_print(const char *contents){
if(size > 0){
}
}
void U_WMROFFSETVIEWPORTORG_print(const char *contents){
if(size){
}
}
void U_WMRSCALEVIEWPORTEXT_print(const char *contents){
if(size > 0){
}
}
void U_WMRLINETO_print(const char *contents){
if(size){
}
}
void U_WMRMOVETO_print(const char *contents){
if(size > 0){
}
}
void U_WMREXCLUDECLIPRECT_print(const char *contents){
if(size > 0){
printf(" Rect:");
printf("\n");
}
}
void U_WMRINTERSECTCLIPRECT_print(const char *contents){
if(size > 0){
printf(" Rect:");
printf("\n");
}
}
void U_WMRARC_print(const char *contents){
if(size > 0){
}
}
void U_WMRELLIPSE_print(const char *contents){
if(size > 0){
printf(" Rect:");
printf("\n");
}
}
void U_WMRFLOODFILL_print(const char *contents){
if(size > 0){
}
}
void U_WMRPIE_print(const char *contents){
if(size > 0){
}
}
void U_WMRRECTANGLE_print(const char *contents){
if(size > 0){
printf(" Rect:");
printf("\n");
}
}
void U_WMRROUNDRECT_print(const char *contents){
if(size > 0){
printf(" Rect:");
printf("\n");
}
}
void U_WMRPATBLT_print(const char *contents){
if(size > 0){
}
}
void U_WMRSAVEDC_print(const char *contents){
(void) contents;
/* This record type has only the common 6 bytes, so nothing (else) to print */
}
void U_WMRSETPIXEL_print(const char *contents){
if(size > 0){
}
}
void U_WMROFFSETCLIPRGN_print(const char *contents){
if(size > 0){
}
}
void U_WMRTEXTOUT_print(const char *contents){
const char *string;
if(size > 0){
}
}
void U_WMRBITBLT_print(const char *contents){
const char *px;
if(size > 0){
else { printf(" Bitmap16: none\n"); }
}
}
void U_WMRSTRETCHBLT_print(const char *contents){
const char *px;
if(size > 0){
else { printf(" Bitmap16: none\n"); }
}
}
void U_WMRPOLYGON_print(const char *contents){
const char *Data;
if(size > 0){
}
}
void U_WMRPOLYLINE_print(const char *contents){
const char *Data;
if(size > 0){
}
}
void U_WMRESCAPE_print(const char *contents){
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");
}
}
}
void U_WMRRESTOREDC_print(const char *contents){
(void) contents;
/* This record type has only the common 6 bytes, so nothing (else) to print */
}
void U_WMRFILLREGION_print(const char *contents){
if(size > 0){
}
}
void U_WMRFRAMEREGION_print(const char *contents){
if(size > 0){
}
}
void U_WMRINVERTREGION_print(const char *contents){
if(size > 0){
}
}
void U_WMRPAINTREGION_print(const char *contents){
if(size>0){
}
}
void U_WMRSELECTCLIPREGION_print(const char *contents){
if(size>0){
}
}
void U_WMRSELECTOBJECT_print(const char *contents){
if(size>0){
}
}
void U_WMRSETTEXTALIGN_print(const char *contents){
if(size>0){
}
}
void U_WMRCHORD_print(const char *contents){
if(size > 0){
}
}
void U_WMRSETMAPPERFLAGS_print(const char *contents){
if(size > 0){
}
}
void U_WMREXTTEXTOUT_print(const char *contents){
const char *string;
int i;
if(size > 0){
}
printf(" Dx:");
printf("\n");
}
}
void U_WMRSETDIBTODEV_print(const char *contents){
const char *dib;
if(size > 0){
}
}
void U_WMRSELECTPALETTE_print(const char *contents){
if(size > 0){
}
}
void U_WMRREALIZEPALETTE_print(const char *contents){
(void) contents;
/* This record type has only the common 6 bytes, so nothing (else) to print */
}
void U_WMRANIMATEPALETTE_print(const char *contents){
const char *PalEntries;
if(size > 0){
}
}
void U_WMRSETPALENTRIES_print(const char *contents){
const char *PalEntries;
if(size > 0){
}
}
void U_WMRPOLYPOLYGON_print(const char *contents){
const uint16_t *aPolyCounts;
const char *Points;
if(size > 0){
}
}
void U_WMRRESIZEPALETTE_print(const char *contents){
if(size>0){
}
}
void U_WMRDIBBITBLT_print(const char *contents){
const char *dib;
if(size > 0){
else { printf(" DIB: none\n"); }
}
}
void U_WMRDIBSTRETCHBLT_print(const char *contents){
const char *dib;
if(size > 0){
else { printf(" DIB: none\n"); }
}
}
void U_WMRDIBCREATEPATTERNBRUSH_print(const char *contents){
const char *TBm16;
const char *dib;
if(size > 0){
if(TBm16){
}
else { /* from DIB */
}
}
}
void U_WMRSTRETCHDIB_print(const char *contents){
const char *dib;
if(size > 0){
else { printf(" DIB: none\n"); }
}
}
void U_WMREXTFLOODFILL_print(const char *contents){
if(size > 0){
}
}
void U_WMRDELETEOBJECT_print(const char *contents){
if(size>0){
}
}
void U_WMRCREATEPALETTE_print(const char *contents){
const char *PalEntries;
if(size > 0){
}
}
void U_WMRCREATEPATTERNBRUSH_print(const char *contents){
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");
}
}
void U_WMRCREATEPENINDIRECT_print(const char *contents){
if(size > 0){
}
}
void U_WMRCREATEFONTINDIRECT_print(const char *contents){
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");
}
}
void U_WMRCREATEBRUSHINDIRECT_print(const char *contents){
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");
}
}
}
}
void U_WMRCREATEREGION_print(const char *contents){
const char *region; /* Note, because of possible struct alignment issue have to use char * to reference the data */
if(size > 0){
printf(" Brush:");
}
}
/**
\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 1 /* show record checksums, this is NOT portable, result changes with endian type, useful for debugging */
printf("%-30srecord:%5d type:%3u offset:%8d size:%8u\n",
#else
printf("%-30srecord:%5d type:%3u offset:%8d size:%8u recchecksum:%u\n",
U_wmr_names(iType), recnum, iType, (int) off, (int) size, U_16_checksum((int16_t *)contents, size));
#endif
switch (iType)
{
default: U_WMRNOTIMPLEMENTED_print(contents); break;
} //end of switch
return(size);
}
#ifdef __cplusplus
}
#endif