/** @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 #include #include /* for offsetof() macro */ #include #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 ){ uint16_t hatch; U_COLORREF Color; switch(b.Style){ case U_BS_SOLID: memcpy(&Color, &b.Color, sizeof(U_COLORREF)); printf("Color:"); colorref_print(Color); 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: memcpy(&hatch, b.Data, 2); printf("Hatch:0x%4.4X ", hatch); 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 ){ printf("Height:%d ", *(int16_t *)(font + offsetof(U_FONT,Height ))); printf("Width:%d ", *(int16_t *)(font + offsetof(U_FONT,Width ))); printf("Escapement:%d ", *(int16_t *)(font + offsetof(U_FONT,Escapement ))); printf("Orientation:%d ", *(int16_t *)(font + offsetof(U_FONT,Orientation ))); printf("Weight:%d ", *(int16_t *)(font + offsetof(U_FONT,Weight ))); printf("Italic:0x%2.2X ", *(uint8_t *)(font + offsetof(U_FONT,Italic ))); printf("Underline:0x%2.2X ", *(uint8_t *)(font + offsetof(U_FONT,Underline ))); printf("StrikeOut:0x%2.2X ", *(uint8_t *)(font + offsetof(U_FONT,StrikeOut ))); printf("CharSet:0x%2.2X ", *(uint8_t *)(font + offsetof(U_FONT,CharSet ))); printf("OutPrecision:0x%2.2X ", *(uint8_t *)(font + offsetof(U_FONT,OutPrecision ))); printf("ClipPrecision:0x%2.2X ", *(uint8_t *)(font + offsetof(U_FONT,ClipPrecision ))); printf("Quality:0x%2.2X ", *(uint8_t *)(font + offsetof(U_FONT,Quality ))); printf("PitchAndFamily:0x%2.2X ", *(uint8_t *)(font + offsetof(U_FONT,PitchAndFamily))); printf("FaceName:%s ", (font + offsetof(U_FONT,FaceName ))); } /** \brief Print a U_PLTNTRY object. \param pny U_PLTNTRY object. */ void pltntry_print( U_PLTNTRY pny ){ printf("Value:%u ", pny.Value); printf("Red:%u ", pny.Red ); printf("Green:%u ", pny.Green); printf("Blue:%u ", pny.Blue ); } /** \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; U_PLTNTRY pny; printf("Start:%X ", p->Start ); printf("NumEntries:%u ",p->NumEntries ); if(p->NumEntries && PalEntries){ for(i=0; i < p->NumEntries; i++, PalEntries += sizeof(U_PLTNTRY)){ memcpy(&pny, PalEntries, sizeof(U_PLTNTRY)); printf("%d:",i); pltntry_print(pny); } } } /** \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 ){ U_COLORREF Color; printf("Style:0x%8.8X " ,p.Style ); printf("Width:%u " ,p.Widthw[0] ); memcpy(&Color, &p.Color, sizeof(U_COLORREF)); printf("Color"); colorref_print(Color); } /** \brief Print U_RECT16 object Prints in order left, top, right, bottom \param rect U_RECT16 object */ void rect16_ltrb_print( U_RECT16 rect ){ printf("LTRB{%d,%d,%d,%d} ",rect.left,rect.top,rect.right,rect.bottom); } /** \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( U_RECT16 rect ){ printf("BRTL{%d,%d,%d,%d} ",rect.bottom,rect.right,rect.top,rect.left); } /** \brief Print U_REGION object from a char * pointer. \param region U_REGION object */ void region_print( const char *region ){ U_RECT16 rect16; printf("Type:%d ", *(uint16_t *)(region + offsetof(U_REGION,Type ))); printf("Size:%d ", *( int16_t *)(region + offsetof(U_REGION,Size ))); printf("sCount:%d ",*( int16_t *)(region + offsetof(U_REGION,sCount))); printf("sMax:%d ", *( int16_t *)(region + offsetof(U_REGION,sMax ))); memcpy(&rect16, (region + offsetof(U_REGION,sRect )), sizeof(U_RECT16)); printf("sRect: "); rect16_ltrb_print(rect16); } /** \brief Print U_BITMAP16 object \param b U_BITMAP16 object */ void bitmap16_print( U_BITMAP16 b ){ printf("Type:%d ", b.Type ); printf("Width:%d ", b.Width ); printf("Height:%d ", b.Height ); printf("WidthBytes:%d ", b.WidthBytes); printf("Planes:%d ", b.Planes ); printf("BitsPixel:%d ", b.BitsPixel ); printf("BitsBytes:%d ", (((b.Width * b.BitsPixel + 15) >> 4) << 1) * b.Height ); } /** \brief Print U_BITMAPCOREHEADER object \param ch U_BITMAPCOREHEADER object */ void bitmapcoreheader_print( U_BITMAPCOREHEADER ch ){ uint32_t Size; memcpy(&Size, &(ch.Size_4), 4); /* will be aligned, but is in two pieces */ printf("Size:%d ", Size); printf("Width:%d ", ch.Width); printf("Height:%d ", ch.Height); printf("Planes:%d ", ch.Planes); printf("BitCount:%d ", ch.BitCount); } /** 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 ){ U_COLORREF Color; uint16_t Style = *(uint16_t *)(lb + offsetof(U_WLOGBRUSH,Style)); uint16_t Hatch = *(uint16_t *)(lb + offsetof(U_WLOGBRUSH,Hatch)); memcpy(&Color, lb + offsetof(U_WLOGBRUSH,Color), sizeof(U_COLORREF)); printf("Style:0x%4.4X ",Style); switch(Style){ case U_BS_SOLID: printf("Color:"); colorref_print(Color); 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: printf("Color:"); colorref_print(Color); printf("Hatch:0x%4.4X ", Hatch); 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( uint16_t nPolys, const uint16_t *aPolyCounts, const char *Points ){ int i,j; U_POINT16 pt; for(i=0; i