Lines 862-898
int ImageIO::saveTIFF (Glib::ustring fna
Link Here
|
862 |
// PNG read and write routines: |
862 |
// PNG read and write routines: |
863 |
|
863 |
|
864 |
void png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { |
864 |
void png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { |
865 |
png_size_t check; |
865 |
png_size_t check; |
866 |
|
866 |
|
867 |
/* fread() returns 0 on error, so it is OK to store this in a png_size_t |
867 |
/* fread() returns 0 on error, so it is OK to store this in a png_size_t |
868 |
* instead of an int, which is what fread() actually returns. |
868 |
* instead of an int, which is what fread() actually returns. |
869 |
*/ |
869 |
*/ |
870 |
check = (png_size_t)fread(data, (png_size_t)1, length, (FILE *)png_ptr->io_ptr); |
870 |
check = (png_size_t)fread(data, (png_size_t)1, length, (FILE *)png_get_io_ptr(png_ptr)); |
871 |
|
871 |
|
872 |
if (check != length) |
872 |
if (check != length) |
873 |
{ |
873 |
{ |
874 |
png_error(png_ptr, "Read Error"); |
874 |
png_error(png_ptr, "Read Error"); |
875 |
} |
875 |
} |
876 |
} |
876 |
} |
877 |
|
877 |
|
878 |
void png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) { |
878 |
void png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) { |
879 |
png_uint_32 check; |
879 |
png_uint_32 check; |
880 |
|
880 |
|
881 |
check = fwrite(data, 1, length, (FILE *)(png_ptr->io_ptr)); |
881 |
check = fwrite(data, 1, length, (FILE *)png_get_io_ptr(png_ptr)); |
882 |
if (check != length) |
882 |
if (check != length) |
883 |
{ |
883 |
{ |
884 |
png_error(png_ptr, "Write Error"); |
884 |
png_error(png_ptr, "Write Error"); |
885 |
} |
885 |
} |
886 |
} |
886 |
} |
887 |
|
887 |
|
888 |
void png_flush(png_structp png_ptr) { |
888 |
void png_flush(png_structp png_ptr) { |
889 |
FILE *io_ptr; |
889 |
FILE *io_ptr; |
890 |
io_ptr = (FILE *)CVT_PTR((png_ptr->io_ptr)); |
890 |
io_ptr = (FILE *)(png_get_io_ptr(png_ptr)); |
891 |
if (io_ptr != NULL) |
891 |
if (io_ptr != NULL) |
892 |
fflush(io_ptr); |
892 |
fflush(io_ptr); |
893 |
} |
893 |
} |
894 |
|
894 |
|
895 |
int ImageIO::load (Glib::ustring fname) { |
895 |
int ImageIO::load (Glib::ustring fname) { |
896 |
|
896 |
|
897 |
int lastdot = fname.find_last_of ('.'); |
897 |
int lastdot = fname.find_last_of ('.'); |
898 |
if( Glib::ustring::npos == lastdot ) |
898 |
if( Glib::ustring::npos == lastdot ) |