- check = fwrite(data, 1, length, (FILE *)(png_ptr->io_ptr));
+ if(png_ptr == NULL) return;
+#if defined(_WIN32_WCE)
+ if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
+ check = 0;
+#else
+ check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr));
+#endif