/* This file is part of PSPFormat, a File Format plugin for Adobe Photoshop Copyright (C) 2003-7 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 "pspformat.h" #include "zlib.h" enum{ /* the following are maximum sizes, for estimation purposes, * not necessarily correct for all PSP file format versions */ SIZEOF_FILE_HEADER = PSP_SIG_LENGTH + 4, SIZEOF_BLOCK_HEADER = 14, SIZEOF_LAYER_INFO_CHUNK = PSP_LAYER_NAME_MAX+83+PSP_BLEND_RANGE_BYTES, }; OSErr estimate_start(FormatRecordPtr pb, intptr_t *data){ OSErr e = noErr; /* to communicate these values to the later Write phase, we *have* to use Photoshop's data parameter; globals are reinitialised between phases. */ G->psprb = pb->imageMode == plugInModeBitmap ? PAD4(pb->imageSize.h) : pb->imageSize.h; G->channelsize = (long)G->psprb * pb->imageSize.v; // tell Photoshop we're finished with image data pb->data = NULL; return e; } OSErr estimate_finish(FormatRecordPtr pb, intptr_t *data){ // estimate how large we expect the file will be pb->minDataBytes = SIZEOF_FILE_HEADER + SIZEOF_BLOCK_HEADER + 46 /* general image attributes */ + (pb->imageMode == plugInModeIndexedColor) * (SIZEOF_BLOCK_HEADER + 8 + sizeof(RGBQUAD)*256) /* optional palette */ + SIZEOF_BLOCK_HEADER /* layer start block */ /* first layer */ + SIZEOF_BLOCK_HEADER /* layer block */ + SIZEOF_LAYER_INFO_CHUNK + 8 /* layer bitmap chunk */ + pb->planes*( SIZEOF_BLOCK_HEADER + 28 /* channel info */ ) ; pb->maxDataBytes = pb->minDataBytes + pb->planes * G->channelsize; pb->minRsrcBytes = pb->maxRsrcBytes = 0; return noErr; }