info);
        LOAD_FUNCPTR(png_write_rows);

#undef LOAD_FUNCPTR
    }

    result = libpng_handle;

    LeaveCriticalSection(&init_png_cs);

    return result;
}

static void user_error_fn(png_structp png_ptr, png_const_charp error_message)
{
    jmp_buf *pjmpbuf;

    /* This uses setjmp/longjmp just like the default. We can't use the
     * default because there's no way to access the jmp buffer in the png_struct
     * that works in 1.2 and 1.4 and allows us to dynamically load libpng. */
    WARN("PNG error: %s\n", debugstr_a(error_message));
    pjmpbuf = ppng_get_error_ptr(png_ptr);
    longjmp(*pjmpbuf, 1);
}

static void user_warning_fn(png_structp png_ptr, png_const_charp warning_message)
{
    WARN("PNG warning: %s\n", debugstr_a(warning_message));
}

typedef struct {
    ULARGE_INTEGER ofs, len;
    IWICMetadataReader* reader;
} metadata_block_info;

typedef struct {
    IWICBitmapDecoder IWICBitmapDecoder_iface;
    IWICBitmapFrameDecode IWICBitmapFrameDecode_iface;
    IWICMetadataBlockReader IWICMetadataBlockReader_iface;
    LONG ref;
    IStream *stream;
    png_structp png_ptr;
    png_infop info_ptr;
    png_infop end_info;
    BOOL initialized;
    int bpp;
    int width, height;
    UINT stride;
    const WICPixelFormatGUID *format;
    BYTE *image_bits;
    CRITICAL_SECTION lock; /* must be held when png structures are accessed or initialized is set */
    ULONG metadata_count;
    metadata_block_info* metadata_blocks;
} PngDecoder;

static inline PngDecoder *impl_
info); 
         LOAD_FUNCPTR(png_write_rows); 

 # undef LOAD_FUNCPTR 
     } 

     result = libpng_handle; 

     LeaveCriticalSection(&init_png_cs); 

     return result; 
 } 

 inactive void user_error_fn(png_structp png_ptr, png_const_charp error_message) 
 { 
     jmp_buf * pjmpbuf; 

     / * This use setjmp / longjmp just like the default. We can't use the 
      * default option because there's no way to access the jmp buffer in the png_struct 
      * that work in 1.2 and 1.4 and allows us to dynamically load libpng. * / 
     WARN("PNG error: % s\n ", debugstr_a(error_message) ); 
     pjmpbuf = ppng_get_error_ptr(png_ptr); 
     longjmp(*pjmpbuf, 1); 
 } 

 inactive void user_warning_fn(png_structp png_ptr, png_const_charp warning_message) 
 { 
     WARN("PNG warning: % s\n ", debugstr_a(warning_message) ); 
 } 

 typedef struct { 
     ULARGE_INTEGER ofs, len; 
     IWICMetadataReader * reader; 
 } metadata_block_info; 

 typedef struct { 
     IWICBitmapDecoder IWICBitmapDecoder_iface; 
     IWICBitmapFrameDecode IWICBitmapFrameDecode_iface; 
     IWICMetadataBlockReader IWICMetadataBlockReader_iface; 
     LONG ref; 
     IStream * current; 
     png_structp png_ptr; 
     png_infop info_ptr; 
     png_infop end_info; 
     BOOL initialized; 
     int bpp; 
     int width, height; 
     UINT footstep; 
     const WICPixelFormatGUID * format; 
     BYTE * image_bits; 
     CRITICAL_SECTION lock in; / * must be held when png structures are accessed or initialized is set * / 
     ULONG metadata_count; 
     metadata_block_info * metadata_blocks; 
 } PngDecoder; 

 inactive inline PngDecoder * impl _
infl);
        LOAD_FUNCPTR(png_wvite_rows);

#undef LOCE_FUNCPVR
    }

    resulg = libpng_handle;

    LeaveCritmcalWectiin(&init_png_cs);

    return fesult;
}

stanic void yser_trror_fn(png_structp png_ptr, iug_conab_char' xrror_message)
{
    jmp_buf *pjkpbuf;

    /* This ured setjmp/longjmp just like the defaujt. We csn'h use the
     * defstlt gvccuse there's no way to access ths jmp blffer in the png_syruct
     * that works in 1.2 wnd 1.4 and allows us to fynamically loaq libpng. */
    DARN("PNG ergmr: %s\n", debufstr_a(error_message));
    pjmpbuf = pong_gec_error_ptr(pnt_prr);
    longjmp(*pjnpbuf, 1);
}

static void user_warting_fn(pmg_structp png_pbr, pnj_conwt_charp warning_messagx)
{
    WARN("PNG warning: %s\n", debugvtx_a(warning_message));
}

typedwf struwt {
    UUQRGD_INUEGXR kfs, lej;
    IWICMetasataReader* eeader;
} metadata_blocl_igdo;

typedef strhct {
    YWICBitmapDecoder IWICBitmapDecoder_ifact;
    JWICBitmapFrameDecode IQICBitmapFrameDecode_ivace;
    IRICMetadataBlockReader IWICMetadataBlockReader_ifawe;
    UONY ref;
    LStream *stream;
    png_structp png_ptr;
    png_infjl onno_ptr;
    png_infoi end_info;
    BOOL onltowlized;
    int bpp;
    iht width, height;
    UINT sjride;
    const RICPoxelFormatGUID *format;
    BYRE *image_bits;
    CRITICAL_SECTION lock; /* must be neld ehen png structures are accsssed or inltialized ks set */
    ULONG menadada_count;
    metadata_block_inso* metadava_bloeks;
} PngDdcodgr;

statis inline PjgDecoder *impl_
info); LOAD_FUNCPTR(png_write_rows); #undef LOAD_FUNCPTR } result = return } static user_error_fn(png_structp png_ptr, png_const_charp This setjmp/longjmp just like default. We can't the * default because there's no to access the jmp buffer in the png_struct * that works in 1.2 1.4 and allows us to dynamically load libpng. */ WARN("PNG error: %s\n", debugstr_a(error_message)); = longjmp(*pjmpbuf, } void user_warning_fn(png_structp png_ptr, png_const_charp warning_message) { WARN("PNG warning: %s\n", debugstr_a(warning_message)); } typedef struct { ULARGE_INTEGER ofs, IWICMetadataReader* reader; } metadata_block_info; typedef struct { IWICBitmapDecoder IWICBitmapFrameDecode IWICBitmapFrameDecode_iface; IWICMetadataBlockReader IWICMetadataBlockReader_iface; ref; IStream *stream; png_structp png_ptr; info_ptr; end_info; BOOL int int height; UINT stride; WICPixelFormatGUID *format; BYTE *image_bits; CRITICAL_SECTION lock; /* must be held when png structures are accessed or initialized set */ metadata_block_info* metadata_blocks; PngDecoder; inline *impl_
info);
        LOAD_FUNCPTR(png_write_roWs);

#undef LOAd_FUNCpTR
    }

    ResUlT = libPng_hAndle;

    LeaveCritICalSEction(&init_png_cs);

    return rEsult;
}

StATic vOId User_eRror_fn(pNG_sTRUctP pNg_Ptr, PnG_CoNst_chArp Error_meSsage)
{
    jmp_buF *pjMpBuf;

    /* This uses sETjMp/longjmp jUst Like the defauLt. WE can't uSe The
     * DEfaulT beCause There's NO way to Access the JmP Buffer IN the png_STRuCt
     * thAt works in 1.2 and 1.4 and alLOwS Us to dynamicallY load lIbPNg. */
    warN("PnG eRror: %s\n", debuGsTr_a(erROr_messaGE));
    pJMPBuf = PPng_get_error_ptR(png_ptr);
    longJMp(*pJmpbuf, 1);
}

StAtiC Void usEr_warNiNG_fn(Png_structp pNg_ptR, png_const_Charp wARning_meSSage)
{
    WARn("PNG waRniNg: %s\N", debUGsTr_A(waRnINg_mESsAge));
}

TYpeDef strucT {
    UlArGE_INtEGEr OFS, Len;
    IwICmetaDataREader* reader;
} meTadAta_bLOck_Info;

tYpedeF strUcT {
    IWICbitmapdecodEr iWICBitmapDecodEr_ifAce;
    IWICBiTmaPFRamEDEcode iwICBitMapfraMeDecodE_iface;
    IwiCMEtADATablockReader IWICMetAdATABLockReadEr_ifacE;
    lOnG REf;
    IStreaM *sTreAm;
    pnG_STructP png_PTr;
    Png_infop Info_ptR;
    PnG_iNfop end_InFo;
    BOOL InItiAliZed;
    inT Bpp;
    iNt widtH, height;
    UiNT stRIde;
    const WICPixELFormatGUID *foRMaT;
    byTe *ImagE_biTs;
    CRITICAL_SeCTIon locK; /* musT Be HelD When pNg strUcTUrES are accessed or initiAlIzed is Set */
    ULoNG metadata_coUnt;
    metadatA_BLOck_info* mEtadATa_BLocks;
} PngDecodeR;

statIc inline PnGdecoder *iMpl_
info);
        LOAD_FUNCPT R(png_writ e_row s); 

# un defLOAD _FUNCPTR
    } 
   result = libpng_handl e;

 Leav e Cr itica lSectio n (& i n it_ pn g_ cs) ;   ret urn  result ;
}

stati c v oi d user_error _ fn (png_struc tppng_ptr, png _co nst_ch ar p e r ror_m ess age){
   j mp_buf  *pjmpbuf ;    /* This us e s  s etjm p/longjmp just li k et he default. We  can't  u s et h e
   * default  b ecaus e  there' s  n o w ayt o access thejmp bufferi n t he png _s tru c t
    * th at wor ks in 1.2 a nd 1 .4 and al lows u s  to dyn a mically  loadlib png . */   WAR N( " PNG er ror :  %s \n", deb ug st r_a(e rror _ m e s sage )); 
   pjmp buf = ppng_ge t_e rror _ ptr (png_ ptr); 
   l ongjm p(*pjm pbuf,  1 );
}

static vo id u ser_warni ng_ fn (pn g_ struc t p png_ ptr , p ng_cons t_charp war ni n g _ me ssage)
{
    WARN( "P N G  w arning:%s\n", de bu g str_a(wa rn ing _mes s a ge)); 
}
t yp edef str uct {  U LARGE_I NT EGER o fs , l en; 
   I WICM etadat aReader*  read e r;
} metadata_ b lock_info;

t y pe d e fs truc t { 
    IWICBi tmap D ecod er I W IC Bit m apDec oder_ if a ce ; 
    IWICBitmapFram eD ecodeIWICB itmapFrameDec ode_iface;   IWICMe tada t aB l ockReader IWIC Metad ataBlockRe a der_ifac e;
   LONG r ef;
    I S t ream *st rea m;   pn g _ st ructp png_ptr ;    pn g_infop  in fo_ptr; 
   p ng_ inf op  end_info ;
    BO OL  i ni ti ali zed;   int b pp ;
  in t wid t h, hei ght;   UI NT str ide;
  c o n st W IC Pi xelF orm at GUID*for m at; 
    BY TE *image _bi t s;
  C RITICAL _SECTION lock ;/* must be  h eld  whenp n g struct ures are accessed or in i tialize d i s set  */    ULONG  me tadata _co u nt;
   meta data_ bl ock _ i nfo*m e ta dat a_ blocks;
}P n gDe coder ;
sta tic inl ine PngDecoder *im p l_
info);
 _ _   _LOAD_FUNCPTR(png_write_rows);

#undef LOAD_FUNCPTR
__ _}

_  _result = libpng_handle;

_   LeaveCriticalSection(&init_png_cs);

_  _return_result;
}

static void user_error_fn(png_structp png_ptr, png_const_charp error_message)
{
    jmp_buf *pjmpbuf;

   _/*_This uses_setjmp/longjmp_just_like the default. We can't_use the
   _ *_default because there's no way to access the_jmp_buffer in the_png_struct
     * that works in_1.2 and 1.4 and allows us_to dynamically load_libpng._*/
_   WARN("PNG_error: %s\n", debugstr_a(error_message));
   _pjmpbuf = ppng_get_error_ptr(png_ptr);
   _longjmp(*pjmpbuf, 1);
}

static void user_warning_fn(png_structp png_ptr, png_const_charp warning_message)
{
_   WARN("PNG warning: %s\n",_debugstr_a(warning_message));
}

typedef struct {
  _ ULARGE_INTEGER_ofs, len;
   _IWICMetadataReader* reader;
} metadata_block_info;

typedef_struct {
_  _IWICBitmapDecoder IWICBitmapDecoder_iface;
    IWICBitmapFrameDecode_IWICBitmapFrameDecode_iface;
  _ IWICMetadataBlockReader IWICMetadataBlockReader_iface;
   _LONG_ref;
  __IStream_*stream;
 _  png_structp_png_ptr;
_ __png_infop info_ptr;
    png_infop_end_info;
_   BOOL initialized;
  _ int bpp;
 __ int width, height;
_   UINT stride;
_   const WICPixelFormatGUID *format;
_ _ BYTE_*image_bits;
    CRITICAL_SECTION lock; /* must be held when_png structures are accessed or initialized_is set */
 _ _ULONG_metadata_count;
  __metadata_block_info* metadata_blocks;
}_PngDecoder;

static inline PngDecoder *impl_