/* This file is part of icoformat, a Windows Icon (ICO) File Format plugin for Adobe Photoshop Copyright (C) 2002-2010 Toby Thain, toby@telegraphics.com.au This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "world.h" // must come before Photoshop include #include "PIFormat.h" #include "dbg.h" #include "file_io.h" #include "ico.h" #include "png.h" #ifdef PIFmtCanWriteTransparency // does SDK include transparency? (6.0) #define PS6 #define LAYERTRANS pb->transparencyPlane #else #define LAYERTRANS 0 #endif #ifdef DEBUG #define DPRINTF dprintf #define DBG dbg #else #undef DPRINTF #define DPRINTF #define DBG(s) #endif OSErr read_start(FormatRecordPtr pb); OSErr read_continue(FormatRecordPtr pb); OSErr read_finish(FormatRecordPtr pb); OSErr getimageinfo(FILEREF f, ICONDIRENTRY *pide, ICONIMAGE *pii, int idx, char *desc); OSErr write_start(FormatRecordPtr pb, intptr_t *data); OSErr write_continue(FormatRecordPtr pb, intptr_t *data); OSErr write_finish(FormatRecordPtr pb); OSErr writeICO(FormatRecordPtr pb, intptr_t *data); OSErr estimate_start(FormatRecordPtr pb, intptr_t *data); OSErr estimate_continue(FormatRecordPtr pb, intptr_t *data); OSErr estimate_finish(FormatRecordPtr pb, intptr_t *data); long iconsizeimage(FormatRecordPtr pb, intptr_t *data); long iconbytes(FormatRecordPtr pb, intptr_t *data); OSErr writecolourtable(FormatRecordPtr pb, intptr_t *data); OSErr getPNGinfo(int32 f, ICONDIRENTRY *pide, ICONIMAGE *pii, char *desc); OSErr readPNG(FormatRecordPtr pb, ICONDIRENTRY *pide, ICONIMAGE *pii); void my_read_data(png_structp png_ptr, png_bytep data, png_size_t length); void my_error_fn(png_structp png_ptr, png_const_charp error_msg); void my_warning_fn(png_structp png_ptr, png_const_charp warning_msg); OSErr writePNGheader(FormatRecordPtr pb); OSErr writePNG(FormatRecordPtr pb); void my_write_data(png_structp png_ptr, png_bytep data, png_size_t length); void my_flush_data(png_structp png_ptr); struct globals { int ncols, nbits, ctabsize, black, usepng, oldindex[0x100], newindex[0x100]; }; #define G(X) (((struct globals*)*data)->X) extern int whichicon, iconcount, usepng, inrb; extern StringPtr name; extern FILEREF file; extern BufferID outBufferID; extern unsigned char *outdata, *indata; enum{ UNUSED_INDEX = -1 }; // flag used in newindex array #define PS_BUFFER_ALLOC (pb->bufferProcs->allocateProc) #define PS_BUFFER_LOCK (pb->bufferProcs->lockProc) #define PS_BUFFER_UNLOCK (pb->bufferProcs->unlockProc) #define PS_BUFFER_FREE (pb->bufferProcs->freeProc)