~ubuntu-branches/debian/sid/3depict/sid

« back to all changes in this revision

Viewing changes to src/pngread.c

  • Committer: Bazaar Package Importer
  • Author(s): D Haley
  • Date: 2010-09-22 20:09:24 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100922200924-bkyorwswrntnst4d
Tags: 0.0.2-1
* New upstream version
* Enable parallel build

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#ifdef __cplusplus 
19
19
        extern "C" { 
20
20
#endif
 
21
                
 
22
#include "pngread.h"
21
23
 
22
24
//Unavailable definitions under mac & windows (not sure why)
23
25
#if defined(__APPLE__) || defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
 
26
#ifndef png_infopp_NULL
24
27
#define png_infopp_NULL (png_infopp)NULL
 
28
#endif
 
29
#ifndef int_p_NULL
25
30
#define int_p_NULL (int*)NULL
26
31
#endif
27
 
 
28
 
#include "pngread.h"
 
32
#endif
29
33
 
30
34
int check_if_png(const char *file_name, FILE **fp, unsigned int bytes_to_check)
31
35
{
43
47
      Return nonzero (true) if they match */
44
48
 
45
49
 
46
 
   return(!png_sig_cmp(buf, (png_size_t)0, bytes_to_check));
 
50
   return(!png_sig_cmp((png_byte*)buf, (png_size_t)0, bytes_to_check));
47
51
}
48
52
 
49
53
/* Read a PNG file.  You may want to return an error code if the read
217
221
   /* Allocate the memory to hold the image using the fields of info_ptr. */
218
222
 
219
223
   /* The easiest way to read the image: */
220
 
   if (!(*row_pointers = malloc(*height * sizeof(png_bytep)))) {
 
224
   if (!(*row_pointers = (png_byte**)malloc(*height * sizeof(png_bytep)))) {
221
225
     return (-1);
222
226
   }
223
227
   int row;
224
228
 
225
229
   for (row = 0; row < *height; row++)
226
230
   {
227
 
      (*row_pointers)[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr,
 
231
      (*row_pointers)[row] = (png_byte*)png_malloc(png_ptr, png_get_rowbytes(png_ptr,
228
232
         info_ptr));
229
233
   }
230
234